I have recently discovered the brilliant has_finder. It allows you to
name your ActiveRecord searches,
and stack them together. It fulfills a similar need to scope_out.
One of my searches is location based, using the excellent plugin
Geokit.
http://geokit.rubyforge.org/. Normally I can do a spatial search like
so:
When I try to do this within a has_finder finder (see below), it
complains
:origin and :within can not be find. It must be accessing the finder
methods
directly without going through Geokit.
It would be nice if this would work. I'm using GeoKit with named_scope
in Rails 2.1.
I got this working and it was really easy.
Models with "acts_as_mappable" have a method for distance_sql(origin,
units=default_units, formula=default_formula). I used this to create my
condition.
I am using anonymous scopes in a Search model which provides search for
an Organization model, but a similar technique should work with
named_scope. See this Railscast on creating a search with anonymous
scopes: #112 Anonymous Scopes - RailsCasts
I have "acts_as_mappable" on both my Search model and on my Organization
model. This allows me to build a scope condition like this: