Doorkeeper: Blockers to using Doorkeeper in an engine

Created on 4 Feb 2014  路  4Comments  路  Source: doorkeeper-gem/doorkeeper

I would love to use Doorkeeper in a Rails Engine with isolate_namespace enabled, but I'm discovering that there are some blockers to making that happen. Opening this ticket to track them and discuss possible fixes.

  1. Routing problems with scopes (#328).
  2. Views aren't executed in the isolated namespace, so the helpers aren't found. For example, this does not work:

ruby <%= form_tag oauth_authorization_path, :method => :post do %>

It works if given the engine routing helper:

ruby <%= form_tag my_engine.oauth_authorization_path, :method => :post do %>

So either the views need to account for a routing helper, or we need to change what context they run in. Devise somehow doesn't use the helper and their paths still work. Not sure how they are achieving that.

  1. It would be nice to have a way to control what base class Doorkeeper::ApplicationController inherits from. something like:
    ruby Doorkeeper.configure do base_controller 'MyEngine::ApplicationController' end
refactor

Most helpful comment

Simple workaround for that issue:

  1. Add to first line of config/initializers/doorkeeper.rb: Doorkeeper::ApplicationController.send(:include, YourEngine::Engine.routes.url_helpers)
  2. require 'dookeeper' in lib/your_engine.rb
  3. Add ref in module YourEngine located in lib/your_engine.rb like that:
module YourEngine
  Doorkeeper = ::Doorkeeper
end

All 4 comments

Simple workaround for that issue:

  1. Add to first line of config/initializers/doorkeeper.rb: Doorkeeper::ApplicationController.send(:include, YourEngine::Engine.routes.url_helpers)
  2. require 'dookeeper' in lib/your_engine.rb
  3. Add ref in module YourEngine located in lib/your_engine.rb like that:
module YourEngine
  Doorkeeper = ::Doorkeeper
end

@iangreenleaf did you solve your issue? If so, how? Does the previous comment address the issue? Thanks for your input.

EDIT: Another workaround from @iangreenleaf: https://github.com/doorkeeper-gem/doorkeeper/issues/328#issuecomment-34019343

@tute no, I ended up changing the architecture and not using Doorkeeper in an engine, so I didn't make progress beyond my initial spate of workarounds.

Closing for now then. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

f3ndot picture f3ndot  路  6Comments

pakwfoley picture pakwfoley  路  6Comments

amngibson picture amngibson  路  5Comments

beweinreich picture beweinreich  路  5Comments

krtschmr picture krtschmr  路  6Comments