1

When I do

get :inside, :format => :xml, :lat2 => "41", :lng2 => "-73.9", :lat1 => "40", :lng1 => "-74", :category => "girl", :order => "date"

with my routes.rb includes:

get 'images/inside/:lat1/:lng1/:lat2/:lng2/:order/:category', :to => "images#inside"

I get

ActionController::RoutingError: No route matches {:lng1=>"-74", :category=>"girl", :lat2=>"41", :format=>:xml, :lng2=>"-73.9", :order=>"date", :lat1=>"40", :action=>"inside", :controller=>"images"}

But when I do

get :inside, :format => :xml, :lat2 => "41", :lng2 => "-73", :lat1 => "40", :lng1 => "-74", :category => "girl", :order => "date"

it works!

The only difference is the decimal value of lng2.

Note that if routes.rb has no params, it works, but I need those

3
  • beware of your params, it seems you are inverting category and order Jan 10, 2011 at 22:40
  • btw you should url_encode your params. Jan 10, 2011 at 22:42
  • Order does not matter in a hash, and as far as I know, rails is taking in the url encoding in this case. plus, url_encode(".") === ".", so that would not help
    – standup75
    Jan 10, 2011 at 22:47

2 Answers 2

0

As far as I can tell, it's because your value has a period. By default, Rails (at least Rails3) routes cannot contain periods. To work around this, see http://avdi.org/devblog/2010/06/18/rails-3-resource-routes-with-dots-or-how-to-make-a-ruby-developer-go-a-little-bit-insane/

1
  • totally makes sense, looks like I was a bit too much inside my code, thanks!
    – standup75
    Jan 10, 2011 at 23:54
0

I bet the decimal point is making Rails think that there's a format being specified (e.g. .xml or .js).

You might be able to get around it using a regex, something like what's described here: http://zargony.com/2009/05/05/routing-parameters-with-a-dot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.