diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index bc0f6e0..b1abca0 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -7,6 +7,8 @@ class MoviesController < ApplicationController def show @movie = Movie.find(params[:id]) @fans = @movie.fans + @genres = @movie.genres.order(:name) + if current_user @favorite = current_user.favorites.find_by(movie_id: @movie.id) end @@ -43,6 +45,6 @@ class MoviesController < ApplicationController private def movie_params - params.require(:movie).permit(:title, :description, :rating, :released_on, :total_gross, :director, :duration, :image_file_name) + params.require(:movie).permit(:title, :description, :rating, :released_on, :total_gross, :director, :duration, :image_file_name, genre_ids: []) end end diff --git a/app/views/movies/_form.html.erb b/app/views/movies/_form.html.erb index 3a31a44..fb8d72f 100644 --- a/app/views/movies/_form.html.erb +++ b/app/views/movies/_form.html.erb @@ -10,6 +10,10 @@ <%= f.label :rating %> <%= f.select :rating, Movie::RATINGS, prompt: "Pick one" %> +