对于 Rails 3.2,我在 config/routes.rb 中有以下内容
scope "/:locale" do
resource :users, :only => [:new, :create]
namespace :admin do
resources :specifications
end
end
用户路由按预期工作,规范路由除索引外工作。通过 GET 调用“/en/admin/specifications”,返回以下错误:
No route matches {:action=>"show", :controller=>"admin/specifications", :locale=>#<Specification id: 1, name: "Check-in", created_at: "2012-04-28 12:10:29", updated_at: "2012-04-28 12:10:29">}
我做错了什么?
最佳答案
尝试将此添加到您的应用程序 Controller 中:
def default_url_options(options={})
{:locale => I18n.locale}
end
它对我有用,我建议您阅读 I18n 指南的部分,其中解释了如何 set the locale from the URL params .
PS:欢迎来到 StackOverflow ;)
关于ruby-on-rails - Rails 路由 : namespace nested in a scope,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10381241/