The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
The has_many_booleans Rails plugin

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jan Lelis

Posts: 136
Nickname: rbjl
Registered: Aug, 2009

Jan Lelis is an IT student from Dresden/Germany
The has_many_booleans Rails plugin Posted: Jul 9, 2010 12:20 AM
Reply to this message Reply

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.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jan Lelis
Latest Posts From rbJ*_*L.net

Advertisement

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

  • Rails 2: script/plugin install git://github.com/janlelis/has_many_booleans
  • Rails 3: rails plugin install git://github.com/janlelis/has_many_booleans
  • …or get it as a gem: gem install has_many_booleans (and add it to your environment.rb/Gemfile)

Now you have to add an integer field to your model’s table with the name booleans.

How to use

You can activate the plugin wih something like the following in your model file:

class Model < ActiveRecord::Base
  has_many_booleans :name, :password
end

# 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

For more information, see the README ;)

(c) 2010 Jan Lelis.

Read: The has_many_booleans Rails plugin

Topic: RubyLearning Associates and Participants on Twitter and Facebook Previous Topic   Next Topic Topic: High Level Testing with a High Level Language

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use