Search code examples
ruby-on-railsruby-on-rails-3rails-geocoder

Geocoder gem - Displaying nearby other models


Right to the question, i have two models, houses and shops, When i go into my view show, i would like to display not only all nearby houses, but also shops, i am not sure what to put in my controller but at my view it goes something like this for houses, as far for shops if i put the similiar only calling shops, it throws an error as undefined functions for nearbys..

#app/views/houses/show.html.erb

<h3>Houses</h3>
<ul>
<% for house in @house.nearbys(10) %>
  <li><%= link_to house.address, house %> (<%= house.distance.round(2) %> km)</li>
<% end %>
</ul>

Works great for only one model, but for others... I need your help

Thank you in advance


Solution

  • http://media.railscasts.com/assets/episodes/videos/273-geocoder.mp4