So I am following one tutorial that is obviously done in rails 3 and I am using rails 4. I get this error:
ActiveModel::ForbiddenAttributesError
With this code:
def create
@movie = Movie.create!(params[:movie])
flash[:notice] = "#{@movie.title} was successfully created."
redirect_to movies_path
end
Obviously it has something with strong param
You need to make sure that all attributes required to create a
Movie
are whitelisted.Define a method like this in your controller:
And then pass the result of the method into
create!
:Read more about strong parameters in the Rails documentation.