allows attributes of a serialized column to act as more or less first class active_record attributes. Validations and all
Ruby
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.document
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.rdoc
Rakefile
VERSION
active_record_stash.gemspec
init.rb

README.rdoc

Schemaless Attributes on an ActiveRecord model

Simple little ActiveRecord plugin which allows a subset of a models attributes to reside in a serialized column, while still working with form helpers and validators.

# Assuming a Email schema looks like
create_table "emails", :force => true do |t|
  t.string   "email"
  t.datetime "created_at"
  t.datetime "updated_at"
  t.text     "data"
end

# we can invoke the stash helper as follows
stash <fields..>, :in => <column to stash the fields into>

#full example
class Email < ActiveRecord::Base
  validates_presence_of :name, :phone, :email, :content

  stash :phone, :name, :content :in => :data
end

# validations, and form helpers now work on stashed attributes

Getting Started

#Gemfile
gem "active_record_stash"

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2010 Stefan Penner. See LICENSE for details.