GeoCoder for two different models

Hi All,         In my new project i am using geocoder gem for finding the nearest things to a location can i use it for two different models like i have a volunteer model and party model when ever a party created i should find the volunteers which are near to a party.

Can you post what you've tried? I was just working on this last night, with great success, so I may be able to help you.

Walter

The two different models are Party and volunteer. I have to find all the volunteers who are near to a party. Here is mycode

Parties#show def show @party = Party.find(params[:id]) @volunteers = Volunteer.near(@party.latitude, @party.longitude, 10, :order => :distance)

end

and show.html.erb in party views

<ul> <% for volunteer in @volunteers %>        <li><%= link_to volunteer.first_name, volunteer %> (<%= volunteer.distance.round(2) %> miles)</li> <% end %> </ul>

But i am getting the following error

undefined method `to_coordinates' for 17.4359:Float

Got it it should be @volunteers = Volunteer.near([@party.latitude, @party.longitude], 10, :order => :distance)

venkata reddy wrote in post #1026555:

Got it it should be @volunteers = Volunteer.near([@party.latitude, @party.longitude], 10, :order => :distance)

Thank you, venkata! Very little clear and concise documentation out there and this kind of help is much appreciated!