Skip to content

Instantly share code, notes, and snippets.

@mjtko
Forked from drale2k/gist:1810253
Created February 12, 2012 19:06
Show Gist options
  • Save mjtko/1810299 to your computer and use it in GitHub Desktop.
Save mjtko/1810299 to your computer and use it in GitHub Desktop.
class Location < ActiveRecord::Base
DEFAULT_OPTS = {:units => :km}
class << self
def near(coords, radius = 10, opts = {})
options = DEFAULT_OPTS.merge(options)
radius = radius.to_i
# do stuff with coords and radius and options
end
end
end
def index
@locations = if params[:near]
Location.near(params[:near], params[:radius] || 10)
else
Location.all
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment