ok so i have this call
location.requests.group_by(&:song)
location is
>> location = Location.find 4
=> #<Location id: 4, venue: "Rod Laver Arena at Melbourne Park - Melbourne Vic, ...",
showdate: "2010-11-20", created_at: "2010-10-28 01:20:42", updated_at:
"2010-10-28 01:20:42", band_id: nil, artist_name: "Metallica">
location.requests.group_by(&:song)
this call is returning two records "One" and "one" because they are saved that way in the db....any idea on how to redo the group_by to only return one record with both
I am using sqlite
Group_by can also take a code block. So instead of:
location.requests.group_by(&:song)
Do:
location.requests.group_by{|i| i.song.downcase}
See here for pertinent documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With