Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Can't import protected attributes

#26

"import" throws warnings like the following when trying to set protected attributes:

WARNING: Can't mass-assign these protected attributes: id

This has been reported as part of the issue in other tickets such as in #13 Imports with default primary key breaking

It looks like this is due to the way ar-extensions builds the model instances, with new(), in order to run validations. Rails throws the warnings and removes the protected attributes from the instances, and so they are never imported.

This is reasonable behavior in some sense, but you (or at least I) may want to set protected attributes in some scenarios. I committed a patch that allows this behavior through the use of a :write_protected_attrs option.

Github commit

The code is essentially just preempting the remove_attributes_protected_from_mass_assignment() call in active_record/base.rb.

Reported by markisisme · July 1st, 2009 @ 12:30 AM

State: new
Milestone: none
Assigned to: Zach Dennis Zach Dennis

Activity

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.