Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Persist serialization in the model.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 db
Octocat-spinner-32 gemfiles
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Appraisals
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 Guardfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 materializer.gemspec


Persist serialization in the model by front-loading the serialization and storing in the database as a string.


Using Materializer is easy!

How to include an enable it?

It's easy. First, add the gem:

gem 'materializer'

Enable materializer in the models you which to maintain rendered views in.

include Materializer

Then, define one or more materialization profiles:

materialize :into => FIELD_NAME, :using => METHOD_NAME

You'll also need to make a migration to add the column:

t.string FIELD_NAME_json


FIELD_NAME will be populated with the JSON generated from METHOD_NAME on save. METHOD_NAME should be implemented as a serializable_hash method returning a hash.


Some examples on usage:

Materialize data into name_json using the name_as_json method.

materialize :into => :name, :using => :name_as_json

Materialize data into all_json using the as_json method.

materialize :into => :all, :using => :as_json

Pull in objects from other models

materialize :into => :all, :using => :all_as_json

def all_as_json
  { :field1 => field1, :association1 => association1.as_json } 


Materializer is Copyright © 2011 Christopher Meiklejohn. It is free software, and may be redistributed under the terms specified in the LICENSE file.


The materializer gem was written by Christopher Meiklejohn from Swipely, Inc..

Something went wrong with that request. Please try again.