greasepig code snippets

大苔
  • Home
  • Contact
  • Log in

url_for problem in rails

Last week I had a little problem in which sometimes, i.e. only in certain environments, I would get a double-slash in my urls when using url_for, or redirect_to in my rails controllers. In this case, it was Rails 2.1 (already frozen), and it wouldn't happen on the local box or on the company development box, but only on the client's test box. For example: inside foo_controller.rb:

url_for :action => 'bar'

would result in

http://example.com//foo/bar

instead of the desired

http://example.com/foo/bar

A fix for it was to use

url_for :controller => '/foo', :action => 'bar'

but this is not DRY, so I would still like to know what the actual problem is. In this case, when I say "url_for", I was actually using "redirect_to", but that's the resulting function.

Tags: double slash, rails, ruby, url_for

Categories Uncategorized | Send feedback » August 10th, 2009

  • September 2010
    Mon Tue Wed Thu Fri Sat Sun
     << <   > >>
        1 2 3 4 5
    6 7 8 9 10 11 12
    13 14 15 16 17 18 19
    20 21 22 23 24 25 26
    27 28 29 30      
  • greasepig code snippets

    • Recently
    • Archives
    • Categories
    • Latest comments
  • Search

  • Categories

    • All
    • Uncategorized
  • XML Feeds

    • RSS 2.0: Posts, Comments
    • Atom: Posts, Comments
    What is RSS?
powered by b2evolution free blog software

Valid XHTML 1.0 Transitional

Valid CSS!


©2010 by Moss Gross | Contact | Design by Emin Özlem (tilqicom) | Credits: blog software | web hosting | monetizing grey_skale skin 0.1 2c