A simple alternative to acts_as_eav_model.
Switch branches/tags
Clone or download
Pull request Compare This branch is 19 commits behind timlinquist:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



simple_eav provides a more simple alternative to acts_as_eav_model that works with ActiveRecord without any monkey patching. This gem is designed to be a replacement for acts_as_eav_model.

Acts_as_eav_model's purpose is to provide a model with any number of custom attributes. This project has the same purpose. The difference being maintaining utmost compatibility with ActiveRecord::Base.

Version 0.1.0 makes this library, to my knowledge, fully compatible with acts_as_eav_model. This update introduced the ability to specify custom attributes exactly the same as attributes with an actual column in the database ie:

Person.create :attribute_with_column=>true, :attribute_without_column=>true


gem install simple_eav


1. Create the migration for your model

create_table :people do |t|
  t.text  :custom_attributes # Name this column whatever you like just *make sure* it is a TEXT field

2. Configure simple_eav in your model

class Person < ActiveRecord::Base
  include SimpleEav

  configure_simple_eav :custom_attributes # This sets up the serialization for your custom attributes

3. Set and Get custom attributes as if they were a normal attribute on your model

person = Person.new
person.name = 'Joe'
person.name ~> 'Joe'

person = Person.new :name => 'Joe'
person.name ~> 'Joe'

Migrating to simple_eav

I have not done this yet but will hopefully be making the transition soon. I'll update the README once that's complete or let me know what you find if you migrate your project first. At the moment, a migration would be needed that:

- Moves each attribute record to a key => value pair for the simple_eav_column on the model using acts_as_eav_model
- Destroys each attribute record


  • 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.


Tim Linquist


Copyright © 2011 Tim Linquist

See LICENSE for details.