0

这是我的 config/route.rb 的设计部​​分:

devise_for :admin_utilisateurs, :path_names => { :sign_up => 'enregistrer',
                                                 :sign_in => 'connexion',
                                                 :sign_out => 'deconnexion',
                                                 :password => 'mot_de_passe',
                                                 :unlock => 'deverouiller'},
                                :path => 'identification'

这导致以下结果rake routes

        new_admin_utilisateur_session GET    /identification/connexion(.:format)             devise/sessions#new
            admin_utilisateur_session POST   /identification/connexion(.:format)             devise/sessions#create
    destroy_admin_utilisateur_session DELETE /identification/deconnexion(.:format)           devise/sessions#destroy
           admin_utilisateur_password POST   /identification/mot_de_passe(.:format)          devise/passwords#create
       new_admin_utilisateur_password GET    /identification/mot_de_passe/new(.:format)      devise/passwords#new
      edit_admin_utilisateur_password GET    /identification/mot_de_passe/edit(.:format)     devise/passwords#edit
                                      PUT    /identification/mot_de_passe(.:format)          devise/passwords#update
cancel_admin_utilisateur_registration GET    /identification/cancel(.:format)                devise/registrations#cancel
       admin_utilisateur_registration POST   /identification(.:format)                       devise/registrations#create
   new_admin_utilisateur_registration GET    /identification/enregistrer(.:format)           devise/registrations#new
  edit_admin_utilisateur_registration GET    /identification/edit(.:format)                  devise/registrations#edit
                                      PUT    /identification(.:format)                       devise/registrations#update
                                      DELETE /identification(.:format)                       devise/registrations#destroy
       admin_utilisateur_confirmation POST   /identification/confirmation(.:format)          devise/confirmations#create
   new_admin_utilisateur_confirmation GET    /identification/confirmation/new(.:format)      devise/confirmations#new
                                      GET    /identification/confirmation(.:format)          devise/confirmations#show
             admin_utilisateur_unlock POST   /identification/deverouiller(.:format)          devise/unlocks#create
         new_admin_utilisateur_unlock GET    /identification/deverouiller/new(.:format)      devise/unlocks#new
                                      GET    /identification/deverouiller(.:format)          devise/unlocks#show

我该如何更改?例如,路线:

/identification/deverouiller/new

进入

/identification/deverouiller/nouveau

如果我添加:new => 'nouveau':path_names哈希中,那是行不通的。

非常感谢您的帮助

4

2 回答 2

2

一种不需要使用额外 gem 的解决方案是使用带有path_names选项的范围:

scope path_names: { new: 'creer', edit: 'modifier' } do

   devise_for :users

end

有关详细信息,请参阅http://guides.rubyonrails.org/routing.html#overriding-the-new-and-edit-segments

于 2014-04-14T13:49:40.407 回答
1

看起来rails-translate-routesgem可以帮助解决这个问题。查看Fabio Akita 的这篇博文中的I18n 路由部分: Minimal I18n with Rails 3.2,详细了解如何使用 gem - 与 devise 结合 - 将完整的 URL 转换为本地语言。

于 2012-10-18T01:35:10.223 回答