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

List<T>().Add problem C# -

Javascript natural sort array/object and maintain index association -