mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
upto 3.5
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,6 +10,6 @@ class SessionsController < ApplicationController
|
||||
|
||||
def destroy
|
||||
session[:user_id] = nil
|
||||
redirect_to :root
|
||||
redirect_to "/"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user