Skip to content

Instantly share code, notes, and snippets.

@hbdev012
Created March 2, 2012 05:41
Show Gist options
  • Save hbdev012/1955955 to your computer and use it in GitHub Desktop.
Save hbdev012/1955955 to your computer and use it in GitHub Desktop.
assume method usage
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