Within an engine mounted in a dynamic scope, I'm trying to make an link to the same action but another scope (ie. changing the dynamic part of the scope) and it doesn't work.
I need this to build a link to the current page in another locale. The scope defines the locale, and the current page is handled by the engine.
I wrote a failing test to demonstrate the current behavior, which doesn't work. Rails generates an URL with the new scope in the query string, and the old scope in the path.
Is there another way to change the dynamic scope inside the engine ?
Or is this a bug that should be fixed ?
The output is:
"/more-awesomeness/blog/link_to_another_scope" expected but was
failing test to demonstrate how an engine can't change the scope it's…
… mounted on
I'm not sure if we can fix that. Engine's routes don't know anything about the way the engine is mounted. In other words you need to call router from the host, typically main application, to generate such route.
If this is an engine that is rather mounted only in your app, you could use main_app helper, like main_app.url_for(:omg => "something"). If this is an engine that's more generic and you expect that it could be mounted in other engine, you could allow to configure the name of the helper (so you can use something else than main_app).
main_app.url_for(:omg => "something")
I will leave this open for a while, in case someone has any idea on better way to do it, but I think it's a "won't fix"
It's been 5 months, so I'm closing this as wontfix.