When user is logged in we store its user id in the session.
session[:user_id] = user.id
now on all other links in our site, we want the user redirected if session[:user_id] == nil
The way I think it would be done is that it will be done in each of the methods of controller.
def show_customers
if session[:user_id] == nil
redirect_to (:controller => "authentication", :action => "login")
#code related to show_customers goes here
end
but this will need to be done in every method of every controller.
Is there a more sane Rails’y way to do this?
Use a before_filter.