Skip to content
Snippets Groups Projects
Commit 60df0428 authored by Weston Triemstra's avatar Weston Triemstra
Browse files

support :select parameter for options hash given to ActiveRecord.find

parent dd0f7779
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,7 @@ module Geocoder
# +order+ :: column(s) for ORDER BY SQL clause
# +limit+ :: number of records to return (for LIMIT SQL clause)
# +offset+ :: number of records to skip (for OFFSET SQL clause)
# +select+ :: string with the SELECT SQL fragment (e.g. “id, name”)
#
def near_scope_options(latitude, longitude, radius = 20, options = {})
if ActiveRecord::Base.connection.adapter_name == "SQLite"
......@@ -82,7 +83,7 @@ module Geocoder
"POWER(SIN((#{longitude} - #{lon_attr}) * " +
"PI() / 180 / 2), 2) ))"
default_near_scope_options(latitude, longitude, radius, options).merge(
:select => "*, #{distance} AS distance",
:select => "#{options[:select] || '*'}, #{distance} AS distance",
:conditions => \
["#{lat_attr} BETWEEN ? AND ? AND #{lon_attr} BETWEEN ? AND ?"] +
coordinate_bounds(latitude, longitude, radius),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment