Answer the question
In order to leave comments, you need to log in
How to get the sum of values by group from a table?
Hey! I have online records in my database
id | user_id | count | created_at
1 | 1 | 12 | сегодня
2 | 4 | 26 | вчера
Answer the question
In order to leave comments, you need to log in
Revised the architecture of the application. Now there is no such issue. Thanks to all.
@grouped_entities = Entity.order('created_at DESC').group_by { |group| group.created_at.to_date }
<% @grouped_entities.each do |date, record_group| %>
<h1>date</h1>
<% record_group.each do |record| %>
<%= record.some_method_to_display %>
<% end %>
<% end %>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question