1

From my rake routes:

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

So when I click submit button in registration form it moves me to /users.

How can I change it so user_registration POST would be /users/sign_up(.:format) ? I tried something like this:

  devise_for :users

  as :user do
    post 'sign_up' => 'devise/registrations#create', as: 'user_registration'
  end

But there is conflict as user_registration prefix is already generated by devise_for

Marcin Doliwa
  • 3,639
  • 3
  • 37
  • 62

1 Answers1

0

To do what you want, you need to stop generating default registrations#create action. Unfortunately there is no easy way to do so (or customize it). The best approach I can find is to skip generating registration routes for users and define all of them later with devise_scope method:

devise_for :users, skip: :registration
devise_scope :user do
  resource :registration, :as => :user_registration, :only => [ :new, :edit, :update, :destroy ], :path=> "/users", :path_names=> { :new =>"sign_up" }, :controller=>"devise/registrations"  do
    get :cancel
    post :sign_up, action: :create, as: ''
  end
end

This could be probably cleaned up a bit but it generates what you expect:

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

P.S. related problem is discussed in this thread

Community
  • 1
  • 1
Tumas
  • 1,697
  • 11
  • 9