Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

route for Devise sign up form

The Devise wiki has instructions https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-appfor creating a sign_in form anywhere on a site. I wanted to put the sign_up form on the home page.

The sign_in form they recommend begins like this

<%= form_for("user", :url => user_session_path) do |f| %>

Based on what that example and this output from rake routes

new_user_registration GET /users/sign_up(.:format) devise/registrations#new

I started the sign_up form like this on my site home page

<%= form_for("user", :url => new_user_registration_path) do |f| %>

When I revved up the server and tried to sign up a user, I got this error

No route matches [POST] "/users/sign_up"

Try running rake routes for more information on available routes. 

The one thing I notice is that rake routes shows a GET request for the new_user_registration, while my error message is showing a POST. Not sure if that's significant.

Routes.rb



root :to => "home#index"
devise_for :users
resources :users
like image 336
Leahcim Avatar asked Dec 01 '25 06:12

Leahcim


1 Answers

The problem was that this

new_user_registration_path

is the wrong path. That goes to the "new" action

It should have been

user_registration_path

which goes to the "create" action

like image 152
Leahcim Avatar answered Dec 03 '25 19:12

Leahcim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!