Satya's blog - Ruby on Rails auto_link bug

May 09 2009 11:44 Ruby on Rails auto_link bug

In Ruby on Rails, the auto_link helper takes a string and automatically links URLs and email addresses in the string, producing output suitable for a web page. Today we had a URL that ended in a query string, with a slash in the string, like so: .../end?tag=/mom

auto_link wouldn't recognize the slash as part of the link and ended the link at the "tag=" part. After some googling, I located action_view/helpers/text_helper.rb and added the slash before the dash in the regexp for the query string. This is in a constant called AUTO_LINK_RE.

Update: Swivel blog has a better way to fix this, with an initializer.

Last updated: Jun 04 2009 15:58

Tag: rails geeky