In a file called list.rb, I had
attr_accessible :title, :user_id, :updated_at, :created_at
When you run the tests using 'edge' Rails (4.0.0 beta), you get an error like this: "`attr_accessible` is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add
`protected_attributes` to your Gemfile to use old one."
What does this mean? This blog tells you:
http://logicalfriday.com/2012/10/15/sneaking-a-peak-at-rails-4/
Remove the attr_accessible line from your models. In each of the controllers, add at the bottom something like this (for example, this is
list_controller):
private
def app_params
params.require(:list).permit(:title, :user_id, :updated_at, :created_at)
end
and, where you create a new list in the controller (the
create method), instead of
create method), instead of
@list = List.create(params[:list])
you should have
@list = List.create( app_params )
转自:
http://rubyjunction.us/no-more-attr-accessible-in-ruby-on-rails-4