Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Swards's Profile

GitHub User: swards


Comments by Swards


Agreed - There's no need to use 'first' if you use index_by. The hash values are instances as expected.

Another option - use each_with_object

orders.each_with_object({}) { |o,hsh| hsh[o.purchased_at.to_date] = o.total_price }