Validates_acceptance_of, virtual attributes and mass assign

Hi,

I’ve a question concerning validates_acceptance_of method.

Documentation says that the validated attribute is a virtual one,
without a field in db. But when I add such an attribute to my form (say
check_box(:xyz, :agreement)), it’s passed in params[:xyz][:agreement],
but not assigned when calling Xyz.new(params[:xyz]), probably because
corresponding field doesn’t exist in db. I’ve to manually assign it
afterwards.

This is not very convenient, since I’ve to do it in every action that’s
creating Xyz objects. Is there a way to mass assign all attributes, not
only those that have columns in db?

Thanks,
Matt.

On Apr 27, 2006, at 7:18 AM, Matt wrote:

This is not very convenient, since I’ve to do it in every action
that’s
creating Xyz objects. Is there a way to mass assign all attributes,
not
only those that have columns in db?

In the model, use:

attr_accessible :fieldname_confirmation


– Tom M.