开发者

routing scope (":locale") error

Rails 3.0.9

I configured routes according to http://guides.rubyonrails.org/i18n.html#setting-the-locale-from-the-url-params

But seems that info there is not full. My routes.rb:

Myapp::Application.routes.draw do
  scope "(:locale)", :locale => /ru|en/ do
    resources :pages, :only => [:show]
    ...
  end
  match '/:locale' => 'index#index', :locale => /ru|en/
  root :to => 'index#index'
end

As said in doc by link above, the routes should be /ru/... and /en/... So, how c开发者_C百科ould I get the value of :locale from the route? params[:locale] is empty.

Thanks!


Sorry, it must have been a comment, not an answer, but I don't have the right to comment.

Are you getting empty params[:locale] when accessing, say, http://localhost:8080/ or http://localhost:8080/ru ?

Surely, if must be empty when hitting / or /pages/1, but should not be empty when hitting /ru, /en, /ru/pages/1 etc


Problem was in open_id_authentication plugin. Removing it helped.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜