-
-
Save mjtko/1810299 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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