mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
24 lines
455 B
Ruby
24 lines
455 B
Ruby
class RatingsController < ApplicationController
|
|
def index
|
|
@ratings = Rating.all
|
|
end
|
|
|
|
def new
|
|
@rating = Rating.new
|
|
@beers = Beer.all
|
|
end
|
|
|
|
def create
|
|
Rating.create params.require(:rating).permit(:score, :beer_id)
|
|
session[:last_rating] = "#{rating.beer.name} #{rating.score} points"
|
|
|
|
redirect_to ratings_path
|
|
end
|
|
|
|
def destroy
|
|
rating = Rating.find params[:id]
|
|
rating.delete
|
|
redirect_to ratings_path
|
|
end
|
|
end
|