No route matches - after login attempt - even though the route exists?

Posted by datorum on Stack Overflow See other posts from Stack Overflow or by datorum
Published on 2011-01-10T18:52:17Z Indexed on 2011/01/10 18:53 UTC
Read the original article Hit count: 125

Filed under:
|
|

I am working on a rails application and added a simple login system according to a book.

I created the controller admin: rails generate controller admin login logout index

It added the following routes to routes.db

  get "admin/login"
  get "admin/logout"
  get "admin/index"
  1. I can got to http://localhost:3000/admin/login there is no problem at all.
  2. But when I try to login I get: No route matches "/admin/login"!

Now, the first confusing part is that the "login" method of my AdminController is not executed at all.

The second confusing part is that this code works like a charm - redirects everything to /admin/login:

  def authorize
    unless User.find_by_id(session[:user_id]) 
      flash[:notice] = "you need to login" 
      redirect_to :controller => 'admin', :action => 'login'
    end
  end

Sidenotes:

  • I restarted the server several times.
  • I tried a different browser - to be sure there is no caching problem.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about routing