ruby on rails - How to redirect user to login page when user is not logged in -


when user logged in store user id in session.

session[:user_id] = user.id 

now on other links in our site, want user redirected if session[:user_id] == nil

the way think done done in each of methods of controller.

def show_customers    if session[:user_id] == nil      redirect_to (:controller => "authentication", :action => "login")    #code related show_customers goes here end 

but need done in every method of every controller.

is there more sane rails'y way this?

use before_filter.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -