# config/initializers/mass_assignment.rb
ActiveRecord::Base.send(:attr_accessible, nil)
From rails core commit 641a4f6240
# config/application.rb
config.active_record.whitelist_attributes = true
class FooController << ActionController::Base
def create
@foo = Foo.new(post_params)
...
end
def update
@foo.update_attributes(post_params)
...
end
def post_params
@params[:foo].slice(:params, :i_care_about)
end
private :post_params
end
You may want to look at the new(ish) ActiveModel::MassAssignmentSecurity module. It looks like you can filter the attributes in either the controller, or the model via attr_accessible with an ":as" option. This allows for different lists of accessible attributes based on a role. An admin would be able to update more attributes than a normal user, etc. The params can be filtered using sanitize_for_mass_assignment which looks like it may duplicate what you are doing in the post_params method in your controller.
http://api.rubyonrails.org/classes/ActiveModel/MassAssignmentSecurity/ClassMethods.html