Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
find method on acts_as_mappable model with join
1 Post
find method on acts_as_mappable model with join


In the following query Place is acts_as_mappable_model and it has associations to some other model. The Query is to list all location which are nearest to the origin in ascending order. Yes, I am getting the list of locations in the order But I want list some fields from the associated model, In the following query ads.

I mean, I want the query result as place.name,ads.title

locations = Place.find(:all,:limit=>30,:origin => 'calicut',:conditions => "distance < 1000",:joins=>"INNER JOIN ads_places ON places.id=ads_places.place_id INNER JOIN ads ON ads.id=ads_places.ad_id",:order=>'distance ASC')

Please Help me !


1 Post
Login to add your message