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
You need to make sure that all attributes required to create a Movie
are whitelisted.
Define a method like this in your controller:
private
def movie_params
params.require(:movie).permit(:title, :rating, :release_date)
end
And then pass the result of the method into create!
:
def create
@movie = Movie.create!(movie_params)
# ...
end
Read more about strong parameters in the Rails documentation.