safe_attributes
safe_attributes copied to clipboard
Can I create a model instance with one of parameters named *attributes*?
I have a legacy DB. One of the columns is named attributes. It does cause lots of pain even with bad_attribute_names :attributes
. I was trying to call MyModule::MyModel.new(params_with_attributes), but I get an ArgumentError exception in #assign_attributes
at activerecord (4.2.10) lib/active_record/attribute_assignment.rb
saying When assigning attributes, you must pass a hash as an argument.. Is it the dead end? I'm about to rename the column.
I’d rename it or use Sequel. https://github.com/jeremyevans/sequel/blob/master/README.rdoc
Brian
On Oct 1, 2018, at 5:00 PM, Mikhail Titov [email protected] wrote:
I have a legacy DB. One of the columns is named attributes. It does cause lots of pain even with bad_attribute_names :attributes. I was trying to call MyModule::MyModel.new(params_with_attributes), but I get an ArgumentError exception in #assign_attributes at activerecord (4.2.10) lib/active_record/attribute_assignment.rb saying When assigning attributes, you must pass a hash as an argument.. Is it the dead end? I'm about to rename the column.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.