diff --git a/app/controllers/reviews_controller.rb b/app/controllers/reviews_controller.rb index b3d77cc..0c07f2c 100644 --- a/app/controllers/reviews_controller.rb +++ b/app/controllers/reviews_controller.rb @@ -1,2 +1,6 @@ class ReviewsController < ApplicationController + def index + @movie = Movie.find(params[:movie_id]) + @reviews = @movie.reviews + end end diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index d54d205..a321526 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -7,6 +7,9 @@

<%= year_of(@movie) %> • <%= @movie.rating %>

+
+ <%= link_to pluralize(@movie.reviews.size, "review"), movie_reviews_path(@movie) %> +

<%= @movie.description %>

diff --git a/app/views/reviews/index.html.erb b/app/views/reviews/index.html.erb new file mode 100644 index 0000000..95a8d44 --- /dev/null +++ b/app/views/reviews/index.html.erb @@ -0,0 +1,18 @@ +

Reviews for <%= link_to @movie.title, @movie %>

+ + diff --git a/config/routes.rb b/config/routes.rb index 7b6f8ff..97916af 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,5 +2,7 @@ Rails.application.routes.draw do resources :reviews root "movies#index" - resources :movies + resources :movies do + resources :reviews + end end