|
|
@ -1,5 +1,6 @@
|
|
|
|
class ReviewsController < ApplicationController
|
|
|
|
class ReviewsController < ApplicationController
|
|
|
|
before_action :set_movie
|
|
|
|
before_action :set_movie
|
|
|
|
|
|
|
|
before_action :require_signin
|
|
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
def index
|
|
|
|
@reviews = @movie.reviews
|
|
|
|
@reviews = @movie.reviews
|
|
|
@ -9,6 +10,7 @@ class ReviewsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def create
|
|
|
|
def create
|
|
|
|
@review = @movie.reviews.new(review_params)
|
|
|
|
@review = @movie.reviews.new(review_params)
|
|
|
|
|
|
|
|
@review.user = current_user
|
|
|
|
if @review.save
|
|
|
|
if @review.save
|
|
|
|
redirect_to movie_reviews_path(@movie), notice: "Thanks for your review!"
|
|
|
|
redirect_to movie_reviews_path(@movie), notice: "Thanks for your review!"
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -23,6 +25,6 @@ class ReviewsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def review_params
|
|
|
|
def review_params
|
|
|
|
params.require(:review).permit(:name, :stars, :comment)
|
|
|
|
params.require(:review).permit(:stars, :comment)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|