Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9117 (closed enhancement: fixed)

Opened 1 year ago

Last modified 7 months ago

[PATCH] :trailing_slash option support for UrlWriter#url_for

Reported by: juanjo.bazan Assigned to: nzkoz
Priority: normal Milestone:
Component: ActionPack Version: edge
Severity: normal Keywords: ActionController UrlWriter url_for
Cc:

Description

url_for method lacks support for the :trailing_slash option

Attachments

trailing_slash_url_writer.diff (2.7 kB) - added by juanjo.bazan on 02/13/08 00:05:54.
patch updated to edge [8862]
trailing_slash_url_writer_better_tests.diff (3.1 kB) - added by juanjo.bazan on 02/16/08 18:07:22.
Patch updated with smaller(and more) tests

Change History

07/27/07 11:53:42 changed by juanjo.bazan

  • summary changed from :trailing_slash option support for UrlWriter#url_for to [PATCH] :trailing_slash option support for UrlWriter#url_for.

07/27/07 21:41:04 changed by lifofifo

Cool. I'm just intrigued to know if there are any advantages of using a trailing slash.

Thanks.

08/05/07 21:57:57 changed by juanjo.bazan

The :trailing_slash option is present in the url_for of the Base class, so I think it should work also in the UrlWriter class so you can produce the same links from within your site and from you mailer.

About the trailing slash itself, there is the opinion that if you don't specify an archive type (.html...) the correct url should finish with a trailing slash. Aditionally you avoid some server problems(apache/mod_rewrite related).

http://www.google.es/search?q=url+why+trailing+slash

08/30/07 11:00:48 changed by sur

working fine. +1

11/28/07 14:56:37 changed by trevorturk

I've had issues with a lack of a trailing slash, but only when hosting apps with Media Temple. Adding the DirectorySlash Off directive to the Apache config solved the issue, but it did make me wonder why Rails doesn't add the trailing slash by default. I realize this is a bit off-topic, but here's a thread that illustrates the issue I had and the resolution I came to:

http://groups.google.com/group/rubyonrails-deployment/browse_thread/thread/61563b0586ab0474#

11/29/07 22:46:50 changed by david.calavera

+1

02/13/08 00:05:54 changed by juanjo.bazan

  • attachment trailing_slash_url_writer.diff added.

patch updated to edge [8862]

02/13/08 00:21:10 changed by ernesto.jimenez

+1 works fine

02/13/08 00:22:18 changed by ernesto.jimenez

  • keywords changed from ActionController UrlWriter url_for to ActionController UrlWriter url_for verified.

02/15/08 23:34:33 changed by nzkoz

  • keywords changed from ActionController UrlWriter url_for verified to ActionController UrlWriter url_for.

Implementation looks good, but could you break up the test into a few smaller tests.

It will make it easier to follow and produce multiple failures when broken rather than just one.

02/16/08 18:07:22 changed by juanjo.bazan

  • attachment trailing_slash_url_writer_better_tests.diff added.

Patch updated with smaller(and more) tests

02/16/08 18:11:01 changed by juanjo.bazan

  • owner changed from core to nzkoz.

02/17/08 05:06:51 changed by chuyeow

+1 for trailing_slash_url_writer_better_tests.diff

02/18/08 00:42:09 changed by nzkoz

  • status changed from new to closed.
  • resolution set to fixed.

(In [8892]) Add :trailing_slash option to UrlWriter. Closes #9117 [juanjo.bazan]