开发者

Rails 3 I18n routes

I have such routes in my app:

# config/routes.rb
Demo::Application.routes.draw do  
  root :to => "requests#index"
  match 'find' => 'reque开发者_高级运维sts#find'
  get "about/developer"
  get "about/api"
end

All works ok. But I want to enable I18n urls and changed routes: (by the 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

After adding scope lines it gives error:

Exiting C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:160:in `default_controller_and_action': missing :controller (ArgumentError)

What's up? Official guide is wrong?

My Rails version: 3.0.3, Ruby 1.8.7


Does it work if you specify all of the controller/action names?

In other words, try changing:

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

to:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜