mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
added errors to creating new rating
This commit is contained in:
@@ -9,10 +9,15 @@ class RatingsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
rating = Rating.create params.require(:rating).permit(:score, :beer_id)
|
||||
session[:last_rating] = "#{rating.beer.name} #{rating.score} points"
|
||||
@rating = Rating.create params.require(:rating).permit(:score, :beer_id)
|
||||
@rating.user = current_user
|
||||
|
||||
redirect_to ratings_path
|
||||
if @rating.save
|
||||
redirect_to user_path current_user
|
||||
else
|
||||
@beers = Beer.all
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
Reference in New Issue
Block a user