Skip to content

Changing scope in a mounted engine #6854

wants to merge 1 commit into from

4 participants

sigmike commented Jun 25, 2012

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

Ruby on Rails member
Ruby on Rails member
drogus commented Jun 26, 2012

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).

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"

Ruby on Rails member

It's been 5 months, so I'm closing this as wontfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.