2013-08-27 37 views
0

我升級看門6.7中使用和我有use_doorkeeper問題時use_doorkeeper導致問題:在升級之前一個範圍路線

我的路線:

我跟着migration instructions,做了以下:

scope "(:locale)", :locale => /.{2}/ do 
    ... 
    mount Doorkeeper::Engine => '/oauth', as: 'doorkeeper' 
    ... 
    end 

我升級後的航線有:

scope "(:locale)", :locale => /.{2}/ do 
    ... 
    use_doorkeeper 
    ... 
    end 

現在,我得到了一個錯誤,這條線(或其他),我的觀點:

<td><%= link_to application.name, [:oauth, application] %></td> 

路由錯誤

沒有路由匹配{:動作=> 「秀」,:控制器=>「doorkeeper/applications」,:locale =>#< Doorkeeper ::應用程序ID:5,名稱:「我的應用程序」,uid:「xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...」,祕密:「xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...」,redirect_uri:「 http://www.myapp.com「,created_at:」2013-08-26 14:33:38「,updated_at:」2013-08-26 14:33:38「>}

似乎守門人應用程序正在進入語言環境參數。

有什麼想法?

回答

3

如果你按照rails guides,你會在你的ApplicationController中看到如下內容。

before_action :set_locale 

def set_locale 
    I18n.locale = params[:locale] || I18n.default_locale 
end 

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

但是,您的門衛控制器不會繼承您的ApplicationController。所以,如果我是你,我會拉他們趕出以正常方式關心

module LocaleConcern 
    extend ActiveSupport::Concern 

    included do 
    before_action :set_locale 
    end 

    def set_locale 
    I18n.locale = params[:locale] || I18n.default_locale 
    end 

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

end 

然後你可以include這個在自己的ApplicationController。爲了將它添加到門衛中,有很多選項,但你可以做的一件事是將以下內容添加到config/application.rb

config.to_prepare do 
    Doorkeeper::ApplicationController.send :include, LocaleConcern 
end 
+0

你說得對。我們處理locale的方式是根據rails指南,所以我們已經設置了'default url options'和'set locale'。問題仍然存在。 – davidrac

+0

其實等,我想我明白了爲什麼......更新答案 – gregates