jingoro / active_record_serialize_json

Serialize ActiveRecord attributes with JSON

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

== Description

Serialize an ActiveRecord::Base attribute via JSON.

== Download

The latest version of the <b>active_record_serialize_json</b> source archive can be
found at

* https://github.com/flori/active_record_serialize_json

== Installation

You can use rubygems to fetch the gem and install it for you:

  # gem install active_record_serialize_json

== Usage

  class Person < ActiveRecord::Base
    serialize_json :config
  end

  p = Person.new
  p.config = { 'alerts' => false, 'locale' => 'en' }
  p.save

  ActiveRecord::Base.connection.select_one "SELECT config FROM people;"
  #=> {"config"=>"{\"alerts\":false,\"locale\":\"en\"}"}

About

Serialize ActiveRecord attributes with JSON


Languages

Language:Ruby 100.0%