suruen
suruen

Reputation: 135

problem with devise routes (rails 3.1)

I am getting

ActionController::RoutingError (No route matches [POST] "/users/sign_up"):

when I click on this

= button_to "New account", new_registration_path(resource_name), :class => 'newaccount'

I have customized all the controllers (will be adding recaptchas and other stuff), and put them all in users/. Everything seems to be working fine, except for the error mentioned above. BTW, when I click on the button, the browser url goes to /signup and I get a 404 error, plus the RoutingError in the server. However, if I hit refresh in the browser on that same url (/signup), the registration page shows up without problems and I can proceed with the registration!?

Here are my routes:

devise_for :users, :controllers => { 
  :omniauth_callbacks => "users/omniauth_callbacks",
  :confirmations      => "users/confirmations",
  :passwords          => "users/passwords",
  :registrations      => "users/registrations",       
  :sessions           => "users/sessions"
}
devise_scope :user do
  get "signin",   :to => "users/sessions#new",      :as => :signin
  get "signout",  :to => "users/sessions#destroy",  :as => :signout
  get "signup",   :to => "users/registrations#new", :as => :signup
  get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end
root  :to    => 'home#index'
match 'faq'  => 'faq#index'
match 'acct'    => 'user_controls#index', :as => 'user_root'

What am I doing wrong? Any help would be very much appreciated. I am running Rails 3.1 and devise 1.4.5.

Thanks!

Upvotes: 2

Views: 969

Answers (1)

suruen
suruen

Reputation: 135

I was [POST]ing (using button_to "New account", :signup), but my route only defined get "signup". I just changed the button_to to link_to, and problem solved. Thanks!

Upvotes: 2

Related Questions