ruby on rails - use_doorkeeper causes problems when used within a scope route -
i'm upgrading doorkeeper 6.7 , have problem use_doorkeeper:
i followed migration instructions , did following:
my routes before upgrade:
scope "(:locale)", :locale => /.{2}/ ... mount doorkeeper::engine => '/oauth', as: 'doorkeeper' ... end
my routes after upgrade:
scope "(:locale)", :locale => /.{2}/ ... use_doorkeeper ... end
now error line (and others) in view:
<td><%= link_to application.name, [:oauth, application] %></td>
routing error
no route matches {:action=>"show", :controller=>"doorkeeper/applications", :locale=>#< doorkeeper::application id: 5, name: "my app", uid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...", secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...", redirect_uri: "http://www.myapp.com", created_at: "2013-08-26 14:33:38", updated_at: "2013-08-26 14:33:38">}
it seems doorkeeper application getting locale param.
any idea?
if you've followed rails guides, you'll have following in 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
but doorkeeper controllers don't inherit applicationcontroller
. if i'd pull out concern
module localeconcern extend activesupport::concern included 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
then can include
in own applicationcontroller
in normal way. adding doorkeeper, there's lot of options, 1 thing add following config/application.rb
config.to_prepare doorkeeper::applicationcontroller.send :include, localeconcern end
Really nice blog post.provided a helpful information.I hope that you will post more updates like thisRuby on Rails Online Training Bangalore
ReplyDelete