0

Having a routing issue, should be really simple but seems straightforward and just not working:

match '/api/get-locations-by-distance/:latitude/:longitude' => 'api#get_locations_by_distance'

with this call:

http://localhost:3000/api/get-locations-by-distance/34.035645/-118.233434

thx for any ideas

edit #1
If I update it to the following:

match '/api/get-locations-by-distance/:latitude/:longitude/:stub' => 'api#get_locations_by_distance'

and

http://localhost:3000/api/get-locations-by-distance/34.035645/-118.233434/stub

It still doesn't work.

edit #2
I tried adding the :format => false but this doens't seem to help either.

match '/api/get-locations-by-distance/:latitude/:longitude' => 'api#get_locations_by_distance', :format => false

with

http://localhost:3000/api/get-locations-by-distance/34.035645/-118.233434
timpone
  • 19,235
  • 36
  • 121
  • 211

2 Answers2

2

It thinks that .233434 is format

mikdiet
  • 9,859
  • 8
  • 59
  • 68
0

It's like Mik_Die said - the . is the delimiter for the format in Rails.

Here is a work-around: you can specify your own segmentation constraint.

match '/api/get-locations-by-distance/:latitude/:longitude' => 'api#get_locations_by_distance' , 
       :constraints => { :latitude => /\d+\.\d+/ , :longitude  => /\d+\.\d+/ }

See also:

http://x3ro.de/rails-3-routing-parameters-dots/

Tilo
  • 33,354
  • 5
  • 79
  • 106