Skip to content

Instantly share code, notes, and snippets.

@mrinterweb
Created June 25, 2009 21:51
Show Gist options
  • Save mrinterweb/136189 to your computer and use it in GitHub Desktop.
Save mrinterweb/136189 to your computer and use it in GitHub Desktop.
# The following responds to:
# /locations/nearby/45.513906/-122.645548
# /locations/nearby/45.513906/-122.645548/100
# /locations/nearby/45.513906/-122.645548/100/5
# /locations/nearby/45.513906/-122.645548/100/5.xml
# The following urls work now:
# /locations/nearby/45.513906/-122.645548.xml
# /locations/nearby/45.513906/-122.645548/100.xml
#
# :range and :limit are intended to be optional
map.with_options(
:controller => 'locations',
:action => 'nearby',
:requirements => {
:lat => /-?\d+\.\d+/,
:lng => /-?\d+\.\d+/,
:range => /\d*/,
:limit => /\d*/
},
:range => 10,
:limit => 10
) do |nearby|
nearby.connect '/locations/nearby/:lat/:lng.:format'
nearby.connect '/locations/nearby/:lat/:lng/:range.:format'
nearby.connect '/locations/nearby/:lat/:lng/:range/:limit.:format'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment