ruby on rails - Implement the gecoder gem in nested resource loop? -
i implemented geocoder gem based on tutorial on http://railscasts.com/episodes/273-geocoder
this part of house show view template
- @house.location.nearbys(20, {:order => :distance, :units => :km}).each |house| %li = link_to house.name, house_path (#{city.distance.round(2)} km)
this show al other houses distance in km, works fine.
i showed on same house page cities of region house located, this:
%ul.tags - @region.cities.each |city| %li= link_to city.name, country_region_city_path(@country, @region, city)
question: how can implement geocoder gem in @region.cities loop visitor can see on house page how many km drive house cities?
thanks...remco
geocoded objects should have distance_from
method. @house
should have method if follow ryan bates' tutorial.
check docs how use it: https://github.com/alexreisner/geocoder#location-aware-database-queries
you need ask @house it's distance city (within cities loop)
Comments
Post a Comment