mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Edit is now configurable for devise registrations via path_name.
This commit is contained in:
parent
01e029fd9b
commit
b50fa74596
3 changed files with 12 additions and 3 deletions
|
@ -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]
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue