I use ruby ββgeocoder to search by location. I want to limit the search to sites that were officially launched. If someone is looking for zip, this is easy to use with regex. But if someone is looking for a city, I need to convert the city to a zip code, check my mail table and, if positive, return the search results.
api geocoder has a section for reverse geocoding:
reverse_geocoded_by :latitude, :longitude do |obj,results| if geo = results.first obj.city = geo.city obj.zipcode = geo.postal_code obj.country = geo.country_code end end after_validation :reverse_geocode
This is obviously only built for use in the model. But I'm trying to use it in your controller, but obj.zipcode not work at all. Geocoder.search ('san jose, ca') seems to return what I need, I just don't know how to get to it. Here where I am:
if params[:search].present? params [: search]). to_s if params[:search].present? ,: action => 'notlaunched' if params[:search].present?
source share