I have one instance variable with two records.
id item_with_detail_id quantity
100 205 3
101 205 5
Now, i want the result as follows using Active record group_by .
100 205 8
i tried with
@bill_details=@bill_details.group_by{|bd| bd.item_with_detail_id}.values.map(&:first)
but its not working. Please help me to achieve the result.
Finally i solved this problem. As follows
In the controller =>
it will give the following result
And in the view page: