Isolated engine (doorkeeper) - use helper methods from the main_app
ruby-on-rails-3, rubygems
Solution
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:
app/helpers/application_helper.rb
module ApplicationHelper
def my_helper
"hello"
end
end
app/views/doorkeeper/applications/index.html.erb
<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.
Problem
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`