This commit is contained in:
Aaro Koivukangas
2023-08-10 11:44:01 +03:00
parent 23e6537a12
commit 47a476c71c
12 changed files with 76 additions and 36 deletions
@@ -1,2 +1,7 @@
class ApplicationController < ActionController::Base
helper_method :current_user
def current_user
return nil if session[:user_id].nil?
User.find session[:user_id]
end
end
+1 -1
View File
@@ -9,7 +9,7 @@ class RatingsController < ApplicationController
end
def create
Rating.create params.require(:rating).permit(:score, :beer_id)
rating = Rating.create params.require(:rating).permit(:score, :beer_id)
session[:last_rating] = "#{rating.beer.name} #{rating.score} points"
redirect_to ratings_path
+1 -1
View File
@@ -10,6 +10,6 @@ class SessionsController < ApplicationController
def destroy
session[:user_id] = nil
redirect_to :root
redirect_to "/"
end
end
+1
View File
@@ -8,6 +8,7 @@ class UsersController < ApplicationController
# GET /users/1 or /users/1.json
def show
@user = User.find current_user.id
end
# GET /users/new