On Sat, Feb 20, 2010 at 4:00 PM, Conrad Taylor <[email protected]> wrote:
> On Sat, Feb 20, 2010 at 3:02 PM, Daniel Guettler < > [email protected]> wrote: > >> Hi, I just ran into this ActionController::RoutingError and just >> wanted to check if someone can confirm this as a bug in the Rails 3 >> beta gem. >> >> config/routes.rb contains: >> >> get 'login' => 'session#new' >> post 'login' => 'session#create', :as => :login >> >> > Daniel, can you post the complete route? The 'get' and 'post' HTTP verbs > should exist within a member or collection block of a resource block. For > example, > > resources :posts do > collection do > get :search > end > end > > or > > resources :posts do > get :search, :on => :collection > end > > Note: both of the examples are equivalent. > > Next, your routes look ambiguous meaning that you could have easily > implemented this as follows: > > match 'login' => "user_sessions#lnew", :as => :login > Correction: match 'login' => "user_sessions#new", :as => :login > match 'login' => "user_sessions#destroy", :as => :logout > > Lastly, your URLs will look like the following: > > http://localhost:3000/logout > http://localhost:3000/login > > Good luck, > > -Conrad > > >> GET /login works fine: >> >> Started GET "/login" for 127.0.0.1 at 2010-02-20 17:45:49 >> SQL (0.3ms) SET SQL_AUTO_IS_NULL=0 >> Processing by SessionController#new as HTML >> Rendered session/new.html.haml within layouts/application.html.haml >> (77.9ms) >> Completed in 85ms (Views: 84.1ms | ActiveRecord: 0.2ms) with 200 >> >> >> However POST /login gives the following error: >> >> Started POST "/login" for 127.0.0.1 at 2010-02-20 17:45:58 >> SQL (0.3ms) SET SQL_AUTO_IS_NULL=0 >> >> ActionController::RoutingError (No route matches "/login"): >> >> >> rake routes returns the expected urls: >> >> login POST /login >> {:controller=>"session", :action=>"create"} >> GET /login >> {:controller=>"session", :action=>"new"} >> >> >> Thanks, Daniel >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<rubyonrails-talk%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

