rails/rails — Issue #4291: custom assignable primary key and mass assignment filter/warning
Author: sanderhahn
Created: 2012-01-04 10:54:29+00:00
State: open

The MassAssignmentSecurity triggers a warning and seems to clear the primary key when you use a custom set_primary_key and disable the id auto primary key.

Loading development environment (Rails 3.1.3)

ruby-1.9.2-p290 :001 > CurrencyUnit.new({code: 'USD', name: 'Dollar'})
WARNING: Can't mass-assign protected attributes: code
=> #

ruby-1.9.2-p290 :002 > CurrencyUnit.primary_key
=> "code"

Workaround seems to be to mark all attributes attr_accessible, but the operation is not a mass-assignment.