search for: find_and_sort

Displaying 1 result from an estimated 1 matches for "find_and_sort".

2006 Mar 21
2
Sorting by computed temporary field
...which has a zip code. Events have_many rides, and rides belong_to events. When an event is selected, I''d like to be able to show a list of rides to that event, sorted by distance from the logged-in user. What are some ways to do that? Here''s what I can think of: - Make a new find_and_sort method that adds a new @distance member element and sorts the new collection. Would something like this work? def find_and_sort(event_id) @rides = Ride.find(:all, :conditions => {"event_id = ?", event_id})" for ride in @rides ride.newdistance = distance_between_zips(s...