This doesn't work. If I do: config.columns[:vendor_name].sort_by :sql => '(SELECT vendor_name FROM vendors WHERE vendor_id = users.vendor_id)', then it generates this:
SELECT * FROM `users` ORDER BY (SELECT vendor_name FROM vendors WHERE vendor_id = users.vendor_id) ASC LIMIT 0, 10 which gives an error about subquery returning more than one row. The only way for modifying doing :sql on the sort_by call successfully would seem to be in conjuction with a join. I must be missing something - can you show me how to do this ordering by another tables column using only a subquery in the ORDER BY clause? Many thanks, Wes Ed W wrote: > Wes Gamble wrote: > >> I got this working. However, it seems like I am forced to use the >> :method form of sorting, because the :sql option only allows a valid >> ORDER BY clause. >> >> If I wanted to use a join and order by my association's attribute, would >> I have to override the AS sort method itself? I'm assuming so. >> >> > > Perhaps you don't realise that in SQL you can sort on a subquery? > > Ed W > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en -~----------~----~----~----~------~----~------~--~---
