Try one of: - have a separate field saved with the wins/losses precomputed through a before(:save) - execute a sql query directly through DM, with the appropriate sql mumbo-jumbo present - sort on the ruby side afterward
Keep in mind that you'll also have to deal w/ divide-by-zero for the case of 0 losses. -g On Jul 8, 10:55 am, Yuri Smirnov <[email protected]> wrote: > Let's say I have some Player model with `wins` and `losses` attributes. How > do I retrieve players ordered by their win percent? Player.all(order: > 'wins/losses') doesn't work since :order param expects explicit attribute > name and I didn't find any way to make it handle any calculations. > Regards. -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
