This project is archived and is in readonly mode.

#5399 ✓resolved
bug.odesk (at gmail)

Routing problem in rails 3 rc

Reported by bug.odesk (at gmail) | August 18th, 2010 @ 03:04 AM | in 3.0.2

I have route like this

match 'test/:param1/:param2' => 'welcome#index', :as => 'random_welcome'

the i tried to use it

random_welcome_url :param1 => 'test', :param2 => 'test'

and got error

No route matches {:controller=>"welcome", :action=>"index", :param1=>"test", :param2=>"test"}

but opening http://localhost:3000/test/test/test works perfect

full error log attached.

Comments and changes to this ticket

  • bug.odesk (at gmail)

    bug.odesk (at gmail) August 18th, 2010 @ 03:05 AM

    Forgot to say that i tested on this route on empty project and got same error.

  • bug.odesk (at gmail)

    bug.odesk (at gmail) August 18th, 2010 @ 03:05 AM

    • Title changed from “Routing problem” to “Routing problem in rails 3 rc”
  • Andrew White

    Andrew White August 18th, 2010 @ 01:55 PM

    • State changed from “new” to “invalid”
    • Assigned user set to “Andrew White”
    • Importance changed from “” to “Low”

    Works for me:

    # config/routes.db
    Testapp::Application.routes.draw do
      match 'test/:param1/:param2' => 'welcome#index', :as => 'random_welcome'
    end
    
    # script/rails c
    Loading development environment (Rails 3.0.0.rc)
    >> app.random_welcome_url(:param1 => 'test', :param2 => 'test')
    => "http://www.example.com/test/test/test"
    

    The error log doesn't mention random_welcome_url - it seems to be using download_request_url. I also notice that you're using Haml - can you try with a plain ERb template?

  • bug.odesk (at gmail)

    bug.odesk (at gmail) August 18th, 2010 @ 02:25 PM

    I uploaded empty project with one route and few controllers. Can you please check if

    download_request_url :file_token => "aaaaaa33", :file_name => "test.gif"
    

    works for you.

    http://github.com/slbug/testapp/zipball/master

  • Andrew White

    Andrew White August 18th, 2010 @ 02:40 PM

    No need to check it now you've given me the actual code you were using - periods are no accepted by default in params so that /resource/:id(.:format) works. All you need to do is relax the constraint and it'll start working:

    match 'dl/:file_token/:file_name' => 'test#download_request', :as => 'download_request', :file_name => /[^\/]+/
    
  • bug.odesk (at gmail)

    bug.odesk (at gmail) August 18th, 2010 @ 02:53 PM

    Thanks now it works, but when i trying to add regexp for :file_token it fails again.

    match 'dl/:file_token/:file_name' => 'test#download_request', :as => 'download_request', :file_token => /[a-f0-9]{32}/, :file_name => /[^\/]+/
    
    download_request_url :file_token => "85b3a01dd29b77579b17a2fe179bd9ba", :file_name => "test.gif"
    

    Can you tell where is error?

  • Andrew White

    Andrew White August 18th, 2010 @ 03:49 PM

    • Milestone cleared.
    • State changed from “invalid” to “open”
    • Importance changed from “Low” to “High”

    This is a bug in the bundled Regin Regexp parser in Rack::Mount (which underlies the Rails 3 router). It's fixed in Regin 0.3.6 but Rack::Mount is only bundled with Regin 0.3.5.

    In the meantime you can specify the constraint using a repeated block, e.g:

      :file_token = /(?:[a-f0-9]{8}){4}/
    

    Slightly hackish, but it does the job.

  • bug.odesk (at gmail)
  • Jeremy Kemper

    Jeremy Kemper August 19th, 2010 @ 05:22 PM

    • Assigned user changed from “Andrew White” to “josh”
  • Andrew White

    Andrew White August 19th, 2010 @ 10:02 PM

    • State changed from “open” to “resolved”
  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:02 PM

    • Milestone set to 3.0.2

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages