Routing&Engines: fallback on hosting-routes, non-prefixed links?

I’m currently trying to convert an existing non-engine-plugin (for
redmine)
into an engine: Here I ran into some routing issues: a controller in the
plugin uses a layout from the hosting application, the hosting
application
now tries to render links inside this layout within the context of the
plugin’s controller, which fails, as the plugin does not define them,
only
the hosting application does.

the edgeguide on routes(
Getting Started with Engines — Ruby on Rails Guides) says, qualifying
the
main.app will solve this issue:

link_to "Home", main_app.root_path

however, I cannot/do not want to rewrite all the links in the hosting
application: Is there a way to have rails fall back on the links of the
hosting-application, when a route is not found in the plugin?

A somewhat similar problem happens, when I use link_to with an url like:

link_to "My Account", {:controller => "my",:action => :account}

which works fine, when called from the hosting-application(as the
my-controller exists there, but get’s prefixed with the plugin’s
namespace,
when it is called from within a controller inside the plugin, which
gives
a:

ActionController::RoutingError (No route matches
{:controller=>"redmine_config/my", :action=>"account"}):

as the plugin does not define the my-controller.

figured it out: the solution here is to

  • remove the isolate_namespace from the engine: this allows access to
    the routes/route-helpers of the hosting app.
  • do not namespace the controller(app/my_controller instead of
    app/my_plugin/my_controller) you are calling the layout from:
    otherwise,
    this namespace gets prefixed

Am Dienstag, 10. Juli 2012 08:19:52 UTC+2 schrieb
[email protected]: