A caching current user method call
class ApplicationController < ActionController::Base def current_user session[:user_id] ? @current_user ||= User.find(session[:user_id]) : nil end end
11306 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Michael Greenly blog.michaelgreenly.com
class ApplicationController < ActionController::Base def current_user session[:user_id] ? @current_user ||= User.find(session[:user_id]) : nil end end