This project is archived and is in readonly mode.

#4443 ✓resolved
Nando Vieira

url_for doesn't accept dot characters

Reported by Nando Vieira | April 20th, 2010 @ 02:26 PM

When I have a route like

get '/:page' => "pages#show", :constraints => {:page => /.+/}, :as => :page

Rails raises an error if I try to use a route like

<%= link_to "Sample", page_path("sample.pdf") %>

The error:

ActionController::RoutingError in Pages#index
No route matches {:controller=>"pages", :constraints=>{:page=>/.+/}, :page=>"sample.pdf", :action=>"show"}

On line #2 of app/views/pages/index.html.erb

    1: <p>
    2:  <%= link_to "Sample", page_path("sample.pdf") %>
    3: </p>

    app/views/pages/index.html.erb:2:in `_render_template__553364074_2179637920_0'

I made it work by replacing dots for its escaped equivalent:

<%= link_to "Sample", page_path("sample.pdf".gsub(/\./, "%2E")) %>

Here's my setup:

ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]
Rails 3.0.0.beta3

Comments and changes to this ticket

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>

Referenced by

Pages