Created
March 2, 2012 05:41
-
-
Save hbdev012/1955955 to your computer and use it in GitHub Desktop.
assume method usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserController | |
before_filter :current_user | |
def profile | |
# here you can access current_user object returned by before_filter | |
end | |
private | |
def current_user | |
return User.find(session[:user_id]) | |
end | |
end | |
class UserController | |
assume(:current_user) { User.find(session[:user_id]) } | |
def profile | |
#here current_user object is accessible and even you can using the same in your view files. | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment