Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
ActiveRecord JSON serializer
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
gemfiles
lib
spec
.gitignore
.rspec
.rubocop.yml
.travis.yml
Appraisals
Gemfile
Guardfile
LICENSE.txt
README.md
Rakefile
ar_json_serialize.gemspec
defaults.reek

README.md

ActiveRecord Json Serialize

Coverage StatusBuild StatusGem VersionCode Climate

ActiveRecord JSON serializer

Installation

Add this line to your application's Gemfile:

gem 'ar_json_serialize'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ar_json_serialize

Usage

You need to have some text field for storing some specific data in Hash/Array/etc inside you model.

Add next string in your ActiveRecord model:

class Promo < ActiveRecord::Base
  json_serialize :test_column
end

You can set value of this column with any object.

promo = ::Promo.new
promo.test_column = {'key1' => 'value1'}
promo.save!

And use it with full power of Hashie!

promo = ::Promo.last
puts "Our value is #{promo.test_column.key1}"

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.