A caching current user method call
1 2 class ApplicationController < ActionController::Base 3 def current_user 4 session[:user_id] ? @current_user ||= User.find(session[:user_id]) : nil 5 end 6 end
13393 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
1 2 class ApplicationController < ActionController::Base 3 def current_user 4 session[:user_id] ? @current_user ||= User.find(session[:user_id]) : nil 5 end 6 end