You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
574 B
29 lines
574 B
class ReviewsController < ApplicationController
|
|
before_action :set_movie
|
|
|
|
def index
|
|
@reviews = @movie.reviews
|
|
end
|
|
def new
|
|
@review = @movie.reviews.new
|
|
end
|
|
def create
|
|
@review = @movie.reviews.new(review_params)
|
|
if @review.save
|
|
redirect_to movie_reviews_path(@movie), notice: "Thanks for your review!"
|
|
else
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def set_movie
|
|
@movie = Movie.find(params[:movie_id])
|
|
end
|
|
|
|
def review_params
|
|
params.require(:review).permit(:name, :stars, :comment)
|
|
end
|
|
end
|