This post originated from an RSS feed registered with Ruby Buzz
by Jan Lelis.
Original Post: The has_many_booleans Rails plugin
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;).
So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
has_many_booleans is an ActiveRecord plugin which creates virtual boolean attributes for a model. When the object gets saved, the plugin transforms all attributes into a single integer, using a bitset. So you can easily add new attributes without changing the database structure.
How to setup
It is hosted on github, so you can easily install it with
class Model<ActiveRecord::Basehas_many_booleans:name,:passwordend# here are some of the methods you can now use:# a = Model.new# a.name_activated # false# a.name_activated = true# a.name_activated # true