I want my doorkeeper views to use the application layout:
https://github.com/applicake/doorkeeper/wiki/Customizing-views
This contains routes and helper methods from the main application.
For the routes, I can prefix main_app to the path but for the helper method I get the following error:
undefined method `is_active?' for #<ActionDispatch::Routing::RoutesProxy:0xade808c>
<li class="<%= main_app.is_active?("high_voltage/pages", "api") %>"><%= link_to t('developers'), page_path('api') %></li>
Why is this? The helper is in app/helpers/application_helper.rb
If you generated the views and they are placed in app/views/doorkeeper/**
then the engine still uses doorkeeper controllers.
To fix this, you have to include your helper(s) into the engine's ApplicationController
. Let's say you have something like this:
module ApplicationHelper
def my_helper
"hello"
end
end
<p>
<%= my_helper %>
</p>
This won't work until you include your application helpers into doorkeeper controllers. So in config/application.rb
:
class YourApp::Application < Rails::Application
config.to_prepare do
# include only the ApplicationHelper module
Doorkeeper::ApplicationController.helper ApplicationHelper
# include all helpers from your application
Doorkeeper::ApplicationController.helper YourApp::Application.helpers
end
end
this is similar configuration when you want to customize the layout.
A helper method in application_helper.rb would not be a method for main_app.
The main_app variable is an object with a class/module of ActionDispatch::Routing::RoutesProxy.
main_app is a helper that gives you access to your application routes. main_app.page_path('api'), for example.
I'm assuming, with doorkeeper, you need to access the path you want; main_app.highvoltage_page_path('api').some_doorkeeper_active_method
This should hopefully, at least, send you in the right direction, see also:
http://edgeapi.rubyonrails.org/classes/Rails/Engine.html#label-Using+Engine%27s+routes+outside+Engine
Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With