Ruby on Rails
Thursday, January 24, 2013
Feel a litte ittle stupid right now..
where to sort_by?
Am Donnerstag, 24. Januar 2013 09:49:33 UTC+1 schrieb Jordon Bedwell:
On Thu, Jan 24, 2013 at 2:35 AM, Werner <webagent...@googlemail.--com > wrote:
> Hi.. I need some support...
>
> table:
> week_id, user_id, project_id, hours
> ex. =>
> 33, 2, 1, 10
> 34, 2,1,15
> 33, 2, 2, 20
> 35, 3, 1,20
> etc.
>
> Want to display a sum of hours per week_id per user_id
> I have:
>
> @hours = HourUser.includes(:user).group_by { |h| h.week_id }
>
> @hours.keys.sort.each do |hour|
> @hours[hour].collect(&:stunden).sum
>
> Hours are summed up, but not sorted by user_id..
> How to get that?
Hash#sort_by
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Byft_QPuNC4J.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment