Following the ruby on rails guide developer can't mass-assign protected fields but don't get exception trying to do it, right?
But in my case mass-assignment different params through new
method in rails
application:
@edition = Edition.new params[:edition]
raise following exception:
ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: price
Why? Did I understand something incorrectly? Is it a way not to get the mass-assignment exception? It's not convenient to delete protected attributes from hashes before assignments i think.
Update: Edition model:
class Edition < ActiveRecord::Base
attr_accessible :title, :description
attr_protected :price
end
params[:edition].inspect
:
{"title"=>"t", "description"=>"d", "price"=>"123"}