This project is archived and is in readonly mode.

#5994 ✓resolved
Pawel Barcik

routing and url_for doesn't accept dots in the custom parameters

Reported by Pawel Barcik | November 17th, 2010 @ 04:14 PM | in 3.x

hi

In rails routes.rb file I have something like this:

scope '(:locale)', :module => 'website',  :locale => /en|pl/ do
    
    root :to => 'shop#index'
    
    scope 'img' do
      match 's/', :to => 'dynamic_images#index'
      match 's/:system_user_file_id/:size/:dummy/:test', :to => 'dynamic_images#show_system_user_image'
    end
    
end

and when i try to access the image with the url like this :

http://localhost/img/s/21/normal/testjpg/23

or in the console :

reload!;app.url_for({:controller => "website/dynamic_images", :action => "show_system_user_image", :system_user_file_id => "21" , :size => "normal", :dummy => "testjpg", :test => "23"})

the routing works fine, but when i add to any of the parameters a dot "." , for e.g:

http://localhost/img/s/21/normal/test.jpg/23
http://localhost/img/s/21/no.rmal/testjpg/23
http://localhost/img/s/2.1/normal/testjpg/23
http://localhost/img/s/21/normal/testjpg/2.3
reload!;app.url_for({:controller => "website/dynamic_images", :action => "show_system_user_image", :system_user_file_id => "2.1" , :size => "normal", :dummy => "testjpg", :test => "23"})
reload!;app.url_for({:controller => "website/dynamic_images", :action => "show_system_user_image", :system_user_file_id => "21" , :size => "nor.mal", :dummy => "testjpg", :test => "23"})
reload!;app.url_for({:controller => "website/dynamic_images", :action => "show_system_user_image", :system_user_file_id => "21" , :size => "normal", :dummy => "test.jpg", :test => "23"})

I get the errors:
(console errors)

Reloading...
ActionController::RoutingError: No route matches {:controller=>"website/dynamic_images", :action=>"show_system_user_image", :system_user_file_id=>"21", :size=>"normal", :dummy=>"tes.tjpg", :test=>"23"}

from /home/pawel/AptanaStudio3Workspace/ndc_rails3/bundler_files/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:424:in `raise_routing_error'
from /home/pawel/AptanaStudio3Workspace/ndc_rails3/bundler_files/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:406:in `rescue in generate'
from /home/pawel/AptanaStudio3Workspace/ndc_rails3/bundler_files/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:395:in `generate'
from /home/pawel/AptanaStudio3Workspace/ndc_rails3/bundler_files/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:453:in `generate'
from /home/pawel/AptanaStudio3Workspace/ndc_rails3/bundler_files/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:481:in `url_for'
from /home/pawel/AptanaStudio3Workspace/ndc_rails3/bundler_files/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_dispatch/routing/url_for.rb:131:in `url_for'
from (irb):86
from /home/pawel/AptanaStudio3Workspace/ndc_rails3/bundler_files/ruby/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from /home/pawel/AptanaStudio3Workspace/ndc_rails3/bundler_files/ruby/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from /home/pawel/AptanaStudio3Workspace/ndc_rails3/bundler_files/ruby/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'



but this route works fine :

http://localhost/img/s/21/normal/testjpg/2.3

and this url_for command doesn't:

reload!;app.url_for({:controller => "website/dynamic_images", :action => "show_system_user_image", :system_user_file_id => "21" , :size => "normal", :dummy => "testjpg", :test => "2.3"})

my stack details are :


Ubuntu 10.10, Rails 3.0.3

ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
Linux pawel-desktop 2.6.35-23-generic-pae #37-Ubuntu SMP Fri Nov 5 20:57:06 UTC 2010 i686 GNU/Linux

irb -v
irb 0.9.6(09/06/30)

gem -v
1.3.7

Gems included by the bundle:
  * abstract (1.0.0)
  * actionmailer (3.0.3)
  * actionpack (3.0.3)
  * activemerchant (1.9.0)
  * activemodel (3.0.3)
  * activerecord (3.0.3)
  * activeresource (3.0.3)
  * activesupport (3.0.3)
  * arel (2.0.3)
  * braintree (2.6.2)
  * builder (2.1.2)
  * bundler (1.0.3)
  * carrierwave (0.5.0)
  * erubis (2.6.6)
  * hoe (2.7.0)
  * i18n (0.4.2)
  * i18n_routing (0.4.5)
  * json_pure (1.4.6)
  * liquid (2.2.2)
  * mail (2.2.10)
  * mime-types (1.16)
  * mysql (2.8.1)
  * polyglot (0.3.1)
  * rack (1.2.1)
  * rack-mount (0.6.13)
  * rack-test (0.5.6)
  * rails (3.0.3)
  * railties (3.0.3)
  * rake (0.8.7)
  * rake-compiler (0.7.1)
  * rmagick (2.13.1)
  * rubyforge (2.0.4)
  * sqlite3-ruby (1.3.2)
  * thor (0.14.4)
  * treetop (1.4.9)
  * tzinfo (0.3.23)
  * will_paginate (3.0.pre2)

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