Skip to content

Instantly share code, notes, and snippets.

@mokoaki
Created April 14, 2014 01:33
Show Gist options
  • Save mokoaki/10609853 to your computer and use it in GitHub Desktop.
Save mokoaki/10609853 to your computer and use it in GitHub Desktop.
class User
.
.
#クラス変数へのアクセサ
cattr_accessor(:current_user)
.
.
end
class ApplicationController
.
.
def current_user
return @current_user if @current_user
@current_user = User.normal_select.find_by(remember_token: User.encrypt(cookies[:remember_token]), enable: true)
User.current_user = @current_user
end
.
.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment