Hi, I have two table with the following structure ===============Projects Table ===============id| Name | Description ============================================Tasks Table =============================id|project_id|task_name|complete_dt|effort =============================table and task are related by a one-to-many association Is there any way to query Tasks using active record and get effort put in on each day? Doing this via SQL is trivial, but for the life of me haven''t been able to figure out how to do this using the Model Any ideas ? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
What does your SQL look like? I''m a bit confused as to what you mean by "effort put in on each day" Are you just trying to get all tasks where complete_dt = a certain date? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
mitijain123-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2011-May-15 12:15 UTC
Re: ActiveRecord Model Querying
Task.group("complete_dt").sum("effort") On May 15, 4:11 pm, enygmatic <enygma...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > I have two table with the following structure > > ===============> Projects Table > ===============> id| Name | Description > ===============> =============================> Tasks Table > =============================> id|project_id|task_name|complete_dt|effort > =============================> table and task are related by a one-to-many association > > Is there any way to query Tasks using active record and get effort put > in on each day? > > Doing this via SQL is trivial, but for the life of me haven''t been > able to figure out how to do this using the Model > > Any ideas ?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hey, That worked. Thanks for the quick reply :) Regards, Elroy On May 15, 5:15 pm, "mitijain...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <mitijain...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Task.group("complete_dt").sum("effort") > > On May 15, 4:11 pm, enygmatic <enygma...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Hi, > > I have two table with the following structure > > > ===============> > Projects Table > > ===============> > id| Name | Description > > ===============> > =============================> > Tasks Table > > =============================> > id|project_id|task_name|complete_dt|effort > > =============================> > table and task are related by a one-to-many association > > > Is there any way to query Tasks using active record and get effort put > > in on each day? > > > Doing this via SQL is trivial, but for the life of me haven''t been > > able to figure out how to do this using the Model > > > Any ideas ?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.