Rails 3 I18n路线

时间:2011-02-12 09:46:47

标签: ruby-on-rails-3 internationalization

我的应用程序中有这样的路线:

# config/routes.rb
Demo::Application.routes.draw do  
  root :to => "requests#index"
  match 'find' => 'requests#find'
  get "about/developer"
  get "about/api"
end

一切正常。 但我想启用I18n网址并更改路线:official Rails guide):

# config/routes.rb
Demo::Application.routes.draw do
  scope "(:locale)"  do
    root :to => "requests#index"
    get "about/developer"
    get "about/api"
    match 'find' => 'requests#find'
  end
end

添加scope行后,会出错:

  

退出   C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:160:在   `default_controller_and_action“:   缺失:控制器(ArgumentError)

怎么了?官方指南错了吗?

My Rails版本:3.0.3,Ruby 1.8.7

1 个答案:

答案 0 :(得分:4)

如果指定所有控制器/操作名称,它是否有效?

换句话说,尝试更改:

get "about/developer"
get "about/api"

为:

get "about/developer" => "about#developer"
get "about/api" => "about#api"