Nice! That's better :) On Thu, Sep 17, 2009 at 12:49 PM, Chap <[email protected]> wrote: > > That's a good point. > > I ended up going with > Task.find(:all, :select => 'DISTINCT project_id') > > Which isn't that railsy, but seems to use more appropriate sql. > > On Sep 17, 2:56 pm, Pedro Belo <[email protected]> wrote: >> humm. I think the "Rails way" in this case is to define which task you >> want when a project can have multiple, and make it a new association. >> >> Like: >> >> class Project < ActiveRecord::Base >> has_many :tasks >> has_one :last_task, :class_name => 'Task', :order => 'created_at DESC' >> ... >> >> Then you can get tasks with Project.find(:all, :include => :last_task, >> :conditions => 'tasks.id IS NOT NULL').map(&:last_task) >> >> There's certainly a way to do the same with a big sql select/condition >> but I don't think it will be as readable. Either way, :group is not a >> good solution imho because you're not really using any of the >> aggregate functions. >> >> >> >> On Thu, Sep 17, 2009 at 11:07 AM, Chap <[email protected]> wrote: >> >> > Than I only want one returned. > > >
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Heroku" 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/heroku?hl=en -~----------~----~----~----~------~----~------~--~---
