Again I need some help with grouping&sum
Attributes:
user_id, week_id, project_id, hours
1 61 1 20
1 62 1 5
1 62 2 0
1 61 2 15
1 63
What I need is a table row per user
61 62 63...
35 5
View:
<% @hour_users.group_by(&:user_id).each do |user, hours| %>
<tr>
<% hours.each do |h|%>
<td"><%= h.hours %></td>
<% end %>
</tr>
<% end %>
This gives me a row with all week_ids and
on 2013-02-11 11:12
on 2013-02-11 11:18
On 11 February 2013 10:11, Werner <webagentur.laude@googlemail.com> wrote: > > <% end %> > </tr> > <% end %> > > This gives me a row with all week_ids and You need to tell us the classes and relationships, but if you want a row per user why are you not starting @users.each do |user| Colin
on 2013-02-11 11:22
Sorry the posting was send by mistake..
this is the correct question:
Again I need some help with grouping&sum
Attributes:
user_id, week_id, project_id, hours
1 61 1 20
1 62 1 5
1 62 2 0
1 61 2 15
1 63 1 0
What I need is a table row per user like that:
61 62 63(week_id)
35 5 0.. Sum of hours per user of all projects, per week_id
View:
<% @hour_users.group_by(&:user_id).each do |user, hours| %>
<tr>
<% hours.each do |h|%>
<td"><%= h.hours %></td>
<% end %>
</tr>
<% end %>
This gives me a row with all week_id's and the hours per user but not
summed up by project_id.
How do I have to group that ?
Thanks...
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.