Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A simple alternative to acts_as_eav_model.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec Use strings or keys ubiquituosly
.gitignore
.rvmrc Use latest patchlevel
.travis.yml
Gemfile Make Gemfile use the dependencies in the gemspec
LICENSE
README.rdoc Fix dated links to repo
Rakefile
gemspec.rb
simple_eav.gemspec

README.rdoc

simple_eav

UPDATE

Version 1.0.0, is only compatible with >= 3.1. If you are still bound to < 3.1 please use an older version of this gem.

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.

This library, to my knowledge, is 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

Installation

gem install simple_eav

Usage

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

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
end

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.save!
person.name ~> 'Joe'

Contributing

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

Author

Tim Linquist

Copyright

Copyright © 2011 Tim Linquist

See LICENSE for details.

Something went wrong with that request. Please try again.