Please critique this geo scope

I'm just wondering if this looks alright or if it might be bad
practice. Aim is to be able to do a simple geo search as if it were
any regular scope:

class Place < ActiveRecord::Base
...
scope :near, Proc.new { |latitude, longitude, options|
options = options && options.dup || {}
options.reverse_merge!(:range => 1)
where(:id => Tire.search('places') do
filter 'geo_distance', :distance => "#{options[:range]}
km", :location => [latitude, longitude]
end.results.collect(&:id))
}
end

Seems to work. So I could do this for example:

Place.near(51.8481, -8.4794, :range =>
10).where(...).joins(...).includes(...) # other regular Arel stuff

Look alright or is there a proper way?

Not a ruby/rails expert, but looks good to me. Karmi?

On Sat, Oct 15, 2011 at 5:42 PM, Alan alan@iorum.ie wrote:

I'm just wondering if this looks alright or if it might be bad
practice. Aim is to be able to do a simple geo search as if it were
any regular scope:

class Place < ActiveRecord::Base
...
scope :near, Proc.new { |latitude, longitude, options|
options = options && options.dup || {}
options.reverse_merge!(:range => 1)
where(:id => Tire.search('places') do
filter 'geo_distance', :distance => "#{options[:range]}
km", :location => [latitude, longitude]
end.results.collect(&:id))
}
end

Seems to work. So I could do this for example:

Place.near(51.8481, -8.4794, :range =>
10).where(...).joins(...).includes(...) # other regular Arel stuff

Look alright or is there a proper way?