Advertisement
saasbook

application_controller.rb

May 1st, 2012
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.35 KB | None | 0 0
  1. class ApplicationController < ActionController::Base
  2.   before_filter :set_current_user
  3.   protected # prevents method from being invoked by a route
  4.   def set_current_user
  5.     # we exploit the fact that find_by_id(nil) returns nil
  6.     @current_user ||= Moviegoer.find_by_id(session[:user_id])
  7.     redirect_to login_path and return unless @current_user
  8.   end
  9. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement