I'd like some adviceif possile
i have 2 models Location and Listing Location has many Listings Listing
belongs to location. Using teh acts_as_geocodable plugin i have
geocoded the Location model.
this allows me to do a find like so
location = Location.find(:all, :origin => postal_code, :order =>
i would like to include the child objects in the result so i can show
listings sorted by distance.
i posted at railsforum.com and Duplex suggested using :include as
location = Location.find :all, :origin => postal_code,
:order => "distance asc",
:include => :listings #eager-loading for
:conditions => "state = 'published'"
i get mysql error when i try that pasted here to save space
This is my first project so I'm not sure but i think maybe its unable to
do the :include because distance is a generated field or maybe it's
because using :origin already is a type of JOIN query. any ideas? I'm
thinking maybe the way round this is to find a way to do the sql query
directly and bypass rails?
any suggestions welcome