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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -