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.