Created
March 30, 2012 17:33
-
-
Save brandon-beacher/2253206 to your computer and use it in GitHub Desktop.
This file contains 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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
helper_method :current_user | |
def current_user | |
@current_user ||= User.find_by_id(session[:user_id]) | |
end | |
private | |
def require_user | |
unless current_user.present? | |
flash[:info] = "You'll need to sign in to do that!" | |
redirect_to new_sign_in_path | |
end | |
end | |
end |
This file contains 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 UsersController < ApplicationController | |
before_filter :require_user | |
def show | |
@user = User.find(params[:id]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment