I'm working with Ruby on Rails 2.3.8 and I want users to login before accesing any content from the website.
I've written the following in the application_controller
before_filter :login_required
When the app starts, I'm getting an error in the browser (not even from the application itself) saying it failed to redirect the page. And I see in the URL that says http://localhost:3000/session/new
but it won't work.
Then, I've tried to place that filter in another controller, for example in dashboard_controller
, which is the home page, and it worked fine (but it just works for this controller only, and I want it to filter in the entire app).
I then started thinking, and I actually think that the filter is being executed before the entry for one of these two lines are created in routes file:
map.login '/login', :controller => 'sessions', :action => 'new'
map.signup '/signup', :controller => 'users', :action => 'new'
Any help will be appreciated.