2013-02-12 43 views
2

在一个Rails 3.2应用程序中,我使用Devise和path_prefix和本地化的作用域路线。如何在Devise中使用scoped locale + path_prefix?

#routes.rb 
MyApp::Application.routes.draw do 
    scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do 
    devise_for :admins, 
     path_prefix: 'administration', 
    end 

    ...other resources 
    end 
end 

虽然我的所有其他资源的URL在地址栏正确例如/en/resource/1编写,设计路径传递的语言环境作为参数/administration/admins/registrations/login?locale=en

如何鼓励设计使用的格式​​?

回答

1

第一行应替换为第二行。

devise_for :admins, :path_prefix => "administration" 

devise_for :admins, :path => "administration/admins" 

所以,在你的榜样,那就是:

#routes.rb 
MyApp::Application.routes.draw do 
    scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do 
    devise_for :admins, :path => "administration/admins" 

    ...other resources 
    end 
end 

有关devise_for更多信息,请访问此链接:http://rubydoc.info/github/plataformatec/devise/master/ActionDispatch/Routing/Mapper#devise_for-instance_method

相关问题