I'm taking my first steps "on rails". I looked up several questions on stackoverflow and used google A LOT, but still I can't seem to solve my problem.
I´m trying to write a rails app that lets you manage a list of movies, and a list of actors. Movies can have multiple actors (and hence an actor can star in multiple movies).I have two models Movie
and Actor
as well as the joint ActorsMovie
model. As you can see, I want to establish a Two Many-To-Many relationship.
Please find the relevant files here: https://gist.github.com/ecksma/f09d2a6ec631e46eafe9
Even though I added params.require(:movie).permit(:title, :year, actors_attributes:[:actor_id,:name] )
to movies_controller
, I get an Unpermitted parameter: actors
error when I try to create a new movie with an actor.
Command line output https://gist.github.com/ecksma/f09d2a6ec631e46eafe9#file-command_line_output
I have the same problem when I try to create a new actor with movies. The actor is created but I get Unpermitted parameter: movies
, although I added params.require(:actor).permit(:name, movies_attributes:[:title,:year,:movie_id])
to actors_controller
.
Forms and basic CRUD seems to work, except that I can't seem to hook up movies with actors and vice versa.
Any suggestions on what I´m doing wrong?