No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
eileencodes f1fb46f9f9 Bump version number in gemspec
This gem is still unmaintained but I need to test it with Rails 4.1.
2017-06-21 08:24:55 -04:00
gemfiles Bump for Rails 4.1 2017-06-09 08:35:52 -04:00
lib Bump for Rails 4.1 2017-06-09 08:35:52 -04:00
script will it blend? 2011-12-05 11:52:05 -07:00
test get rid of brittle stubs, just use an in-memory sqlite db 2015-05-22 16:53:01 +10:00
.gitignore will it blend? 2011-12-05 11:52:05 -07:00
.travis.yml test it all on 1.8.7 2011-12-05 12:03:42 -07:00
init.rb prepare a gem 2011-12-05 10:47:02 -07:00
LICENSE initial extraction 2009-05-16 17:23:33 -07:00
rails_init.rb prepare a gem 2011-12-05 10:47:02 -07:00
Rakefile remove appraisal reference 2011-12-05 11:57:01 -07:00
README.md put up unmaintained notice 2015-08-25 11:17:01 +10:00
serializable_attributes.gemspec Bump version number in gemspec 2017-06-21 08:24:55 -04:00

UNMAINTAINED

This repo is no longer being maintained as of 2015-08-25.


SerializedAttributes

SerializedAttributes allows you to add an encoded hash to an ActiveRecord model.
This is similar to the built-in ActiveRecord serialization, except that the field is converted to JSON, gzipped, and stored in a BLOB field. This uses the json gem which is much faster than YAML serialization. However, JSON is not nearly as flexible, so you're stuck with strings/integers/dates/etc.

Where possible, ActiveRecord compatible methods are generated so that a migration should be pretty simple. See unit tests for examples.

Some of the code and most of the ideas are taken from Heresy, a ruby implementation of how FriendFeed uses MySQL for schema-free storage.

Supports ActiveRecord 2.2 in ruby 1.8.7, and ActiveRecord 2.3-3.1 in ruby 1.9.3. See Travis CI to see if we support your version of ActiveRecord and ruby.

Setup

Install the plugin into your Rails app.

Usage

class Profile < ActiveRecord::Base
  # assumes #data serializes to raw_data blob field
  serialize_attributes do
    string  :title, :description
    integer :age
    float   :rank, :percentage
    time    :birthday
  end

  # Serializes #data to assumed raw_data blob field
  serialize_attributes :data do
    string  :title, :description
    integer :age
    float   :rank, :percentage
    time    :birthday
  end

  # set the blob field
  serialize_attributes :data, :blob => :serialized_field do
    string  :title, :description
    integer :age
    float   :rank, :percentage
    time    :birthday
  end
end