Ruby on rails 在RubyonRails中使用I18n设置OAuth回调

Ruby on rails 在RubyonRails中使用I18n设置OAuth回调,ruby-on-rails,ruby-on-rails-3,oauth,internationalization,routes,Ruby On Rails,Ruby On Rails 3,Oauth,Internationalization,Routes,在我的RubyonRails应用程序中,我设置了OAuth以使用OmniauthGem。一切顺利,;然而,一旦我将I18n添加到应用程序中,我就很难让它正常工作。具体来说,问题在于回调。如何调整routes.rb代码以正确处理使用I18n的回调 routes.rb scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do resources :sessions, only: [:new, :create, :des

在我的RubyonRails应用程序中,我设置了OAuth以使用OmniauthGem。一切顺利,;然而,一旦我将I18n添加到应用程序中,我就很难让它正常工作。具体来说,问题在于回调。如何调整routes.rb代码以正确处理使用I18n的回调

routes.rb

 scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
   resources :sessions, only: [:new, :create, :destroy]
   root to: 'static_pages#home'

   match 'auth/:provider/callback', to: 'sessions#create'
   match 'auth/failure', to: redirect('/')
   match 'signout', to: 'sessions#destroy', as: 'signout'

   match '/signin',  to: 'sessions#new'
   match '/signout', to: 'sessions#destroy', via: :delete
 end

  match '*path', to: redirect {|params| "/#{I18n.default_locale}/#{CGI::unescape(params[:path])}" }, constraints: lambda { |req| !req.path.starts_with? "/#{I18n.default_locale}/" }
  match '', to: redirect("/#{I18n.default_locale}")
   before_filter :set_locale
     def set_locale
       I18n.locale = params[:locale] if params[:locale].present?
     end

     def default_url_options(options = {})
       {locale: I18n.locale}
     end
应用程序\u控制器.rb

 scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
   resources :sessions, only: [:new, :create, :destroy]
   root to: 'static_pages#home'

   match 'auth/:provider/callback', to: 'sessions#create'
   match 'auth/failure', to: redirect('/')
   match 'signout', to: 'sessions#destroy', as: 'signout'

   match '/signin',  to: 'sessions#new'
   match '/signout', to: 'sessions#destroy', via: :delete
 end

  match '*path', to: redirect {|params| "/#{I18n.default_locale}/#{CGI::unescape(params[:path])}" }, constraints: lambda { |req| !req.path.starts_with? "/#{I18n.default_locale}/" }
  match '', to: redirect("/#{I18n.default_locale}")
   before_filter :set_locale
     def set_locale
       I18n.locale = params[:locale] if params[:locale].present?
     end

     def default_url_options(options = {})
       {locale: I18n.locale}
     end

这个问题的答案可以找到。:locale需要放在括号中:
scope”(:locale)

可以找到这个问题的答案。:locale需要放在括号中:
范围“(:locale)”

问题的确切性质是什么?你能补充更多关于这个问题的细节吗?e、 g.错误、未发生的事情等。问题的确切性质是什么?你能补充更多关于这个问题的细节吗?e、 g.错误、未发生的事情等。