In my app I have a Model
and am retrieving the lat
and lng
values for each row from an external API unrelated to Geocode. At this time all I need Geocode for is the .nearbys
method which lets me find other nearby models
within the default radius (50 miles) or one that I specify.
Normally you "active" a model for Geocode by adding geocoded_by :attribute_name
, where attribute_name
will be used by Geocode when the object is saved to fetch the lat/long coordinates.
Right now I've simply added this to my model to get it to work:
geocoded_by :blargh, latitude: :lat, longitude: :lng
def blargh
end
This seems to work fine. I can open my console, instantiate a Model
, and call model.nearbys
. However, it seems a bit hacky and I'm wondering if there's a better way than just defining a fake method and passing that to geocoded_by
. Many thanks in advance for any help!