Skip to content

Loading…

Mounting an engine at root path creates double slash at start of URL helper paths #2579

Closed
rails-noob opened this Issue · 14 comments

7 participants

@rails-noob

Mount an engine at the root, with a resource named :items (for example).

  #config/routes.rb
  mount Example::Engine, :at => '/', :as => 'example'  # the bug happens with :at => '' too

Then, on 3.1.0rc5 the expression example.items_path returns //items instead of /items. This completely breaks all links.

Pull requests #2577 fixes it for me.

@rails-noob

I forgot to mention: the bug only occurred when calling items_path from outside the engine.

@rails-noob rails-noob closed this
@rails-noob rails-noob reopened this
@rails-noob rails-noob referenced this issue
Commit has since been removed from the repository and is no longer available.
@rails-noob rails-noob referenced this issue
Commit has since been removed from the repository and is no longer available.
@rails-noob rails-noob referenced this issue
Commit has since been removed from the repository and is no longer available.
@rails-noob rails-noob pushed a commit to rails-noob/rails that referenced this issue
rails-noob Fix bug #2579.
Avoids double slash at start of paths when mounting an engine at the root.
43fbb1e
@joelmats

This issue also seems to happen when accessing request.path from within the engine.

@dlindahl

I am also seeing this issue when using request.url and request.fullpath

@rails-noob I see your pull request is now in ActionPack/-Dispatch but it doesn't seem to fix this issue. Any ideas on what the current status of this is since this issue is so old?

@RicSwirrl

I'm still seeing this on request.url when mouting an engine at root, even though #2577 is marked as closed. How can I help with getting this fixed?

@ugisozols

We @ Refinery CMS are experiencing the same issue and have to resort to a dirty hack like .sub("//", "/").

@RicSwirrl

@ugisozols - that's what I've resorted to for now (except it's not that simple as you don't want to replace the '//' after 'http:') !

@ugisozols

@RicSwirrl we're using it on request.fullpath so that's not a problem.

@jipiboily

There's the same kind of dirty hack in Spree too.

@RicSwirrl

@ugisozols unfortunately I need the whole url, as I'm using it as a URI for a resource. :)

@jipiboily

@RicSwirrl a regex could do the job AFAIK

@RicSwirrl

@jipiboily That's how I've solved it - but it would be nice if it could be fixed in Rails. It definitely feels like a bug!

@ugisozols ugisozols added a commit that referenced this issue
@ugisozols ugisozols Add failing test for #2579. 646f327
@pixeltrix
Ruby on Rails member

Fixed by this commit to Journey

@pixeltrix pixeltrix closed this
@RicSwirrl

Teh Awesomez.

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.