Closed
Description
After setting config.whitelist_attributes = false
in application.rb, the model that is acting as a tree raises ActiveModel::MassAssignmentSecurity::Error
. This is, because closure_tree is adding attr_accessible :parent
(https://github.com/mceachen/closure_tree/blob/32da850126336fec6036ad8154a9b1fa738cb30e/lib/closure_tree/model.rb#L17)
def use_attr_accessible?
ActiveRecord::VERSION::MAJOR == 3 &&
defined?(ActiveModel::MassAssignmentSecurity) &&
model_class.ancestors.include?(ActiveModel::MassAssignmentSecurity)
end
I beleive that this happens because of the last condition of use_attr_accessible?
, which returns true even when using strong parameters. A better condition will be model_class.accessible_attributes.empty?
, which returns true only when attr_accessible has been used in the model.
Metadata
Metadata
Assignees
Labels
No labels