Skip to content
This repository

helpers generate incorrect URLs when engine mounted on root #1210

Closed
tomasc opened this Issue · 5 comments

4 participants

Tomas Celizna Farley Knight Damien Mathieu Piotr Sarnacki
Tomas Celizna
tomasc commented

main_app routes.rb

mount MyEngine::Engine => '/', :as => 'my_engine'

my_engine's routes.rb

get 'my_url' => 'MyEngine::Pages#show', :as => :my_url

in views:

my_engine.my_url

results in "http://localhost:3000//my_url" (note the incorrect '//')

Farley Knight

Is there a reason why you use the suffix "_url" in your route name? BTW I attempted to duplicate this without much luck.

Tomas Celizna
tomasc commented

the _url is just a naming, not actual generator (as for example _path or _url). i should have chosen better name.
perhaps i also forgot to say, that the engine is not isolated.
i will try to look for some example on which to show this issue …

Damien Mathieu
Collaborator

I think you should mount your engine as

mount MyEngine::Engine => '', :as => 'my_engine'
Tomas Celizna
tomasc commented

yes, that would make sense, right? unfortunately:

Exiting
/Library/Ruby/Gems/1.8/bundler/gems/rails-82857adc56ef/actionpack/lib/action_dispatch/routing/mapper.rb:1426:in `to_sym': interning empty string (ArgumentError)
    from /Library/Ruby/Gems/1.8/bundler/gems/rails-82857adc56ef/actionpack/lib/action_dispatch/routing/mapper.rb:1426:in `action_path'
    from /Library/Ruby/Gems/1.8/bundler/gems/rails-82857adc56ef/actionpack/lib/action_dispatch/routing/mapper.rb:1421:in `path_for_action'
    from /Library/Ruby/Gems/1.8/bundler/gems/rails-82857adc56ef/actionpack/lib/action_dispatch/routing/mapper.rb:1276:in `match'
    from /Library/Ruby/Gems/1.8/bundler/gems/rails-82857adc56ef/actionpack/lib/action_dispatch/routing/mapper.rb:1477:in `match'
    from /Library/Ruby/Gems/1.8/bundler/gems/rails-82857adc56ef/actionpack/lib/action_dispatch/routing/mapper.rb:420:in `mount'
Damien Mathieu
Collaborator

Right, 1.8 doesn't allows empty strings to be transormed to symbols. If you tried the same in 1.9, it'd work.

Piotr Sarnacki drogus closed this in 0459374
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.