diff --git a/lib/devise/rails/routes.rb b/lib/devise/rails/routes.rb index 091fea3c..3f8d7f26 100644 --- a/lib/devise/rails/routes.rb +++ b/lib/devise/rails/routes.rb @@ -102,8 +102,11 @@ module ActionDispatch::Routing # * :path_names => configure different path names to overwrite defaults :sign_in, :sign_out, :sign_up, # :password, :confirmation, :unlock. # - # devise_for :users, :path_names => { :sign_in => 'login', :sign_out => 'logout', - # :password => 'secret', :confirmation => 'verification', registration: 'register } + # devise_for :users, :path_names => { + # :sign_in => 'login', :sign_out => 'logout', + # :password => 'secret', :confirmation => 'verification', + # registration: 'register', edit: 'edit/profile' + # } # # * :controllers => the controller which should be used. All routes by default points to Devise controllers. # However, if you want them to point to custom controller, you should do: @@ -378,6 +381,7 @@ module ActionDispatch::Routing def devise_registration(mapping, controllers) #:nodoc: path_names = { :new => mapping.path_names[:sign_up], + :edit => mapping.path_names[:edit], :cancel => mapping.path_names[:cancel] } diff --git a/test/rails_app/config/routes.rb b/test/rails_app/config/routes.rb index 9496f86c..ce789037 100644 --- a/test/rails_app/config/routes.rb +++ b/test/rails_app/config/routes.rb @@ -86,7 +86,8 @@ Rails.application.routes.draw do :sign_in => "login", :sign_out => "logout", :password => "secret", :confirmation => "verification", :unlock => "unblock", :sign_up => "register", - :registration => "management", :cancel => "giveup" + :registration => "management", + :cancel => "giveup", :edit => "edit/profile" }, :failure_app => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }, :module => :devise end diff --git a/test/routes_test.rb b/test/routes_test.rb index 3dd539da..3376e914 100644 --- a/test/routes_test.rb +++ b/test/routes_test.rb @@ -157,6 +157,10 @@ class CustomizedRoutingTest < ActionController::TestCase assert_recognizes({:controller => 'devise/registrations', :action => 'new', :locale => 'en'}, '/en/accounts/management/register') end + test 'map account with custom path name for edit registration' do + assert_recognizes({:controller => 'devise/registrations', :action => 'edit', :locale => 'en'}, '/en/accounts/management/edit/profile') + end + test 'map account with custom path name for cancel registration' do assert_recognizes({:controller => 'devise/registrations', :action => 'cancel', :locale => 'en'}, '/en/accounts/management/giveup') end