Class: Kuroko2::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/kuroko2/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/kuroko2/application_controller.rb', line 16

def current_user
  @_current_user ||= begin
    if (id = session[:user_id])
      Kuroko2::User.active.find(id)
    end
  end
rescue ActiveRecord::RecordNotFound
  reset_session
  redirect_to (return_to: url_for(params.permit!.to_h.merge(only_path: true)))
end