Thoughtbot’s Shoulda is a very nice piece of work. Their ActiveRecord macros are also a god-send:

1 should_protect_attributes :family_id, :debit_account_id, :credit_account_id, :created_at, :updated_at

This code will assert that ActiveRecord attributes are somehow protected (either though attr_accessible or attr_protected). But what about the reverse? There isn’t a macro to do that. I happened to need it, so I implemented it on my own fork of Shoulda.

This allows us to specify:

1 should_protect_attributes :family_id, :debit_account_id, :credit_account_id, :created_at, :updated_at
2 should_allow_attributes :family, :debit_account, :credit_account, :amount, :posted_on, :description

NOTE: Example taken from my family budget application.


Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend


Projects I work on

Projects I worked on