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