I want to get distinct records in rails. For that I see this Rails: how can I get unique values from column
But the issue is that by this solution I only get the Ids .
ViewsLog.uniq.pluck(:unit_id)
[24, 21, 23, 4, 16, 5, 7]
I want all columns of uniq unit_id
You can use group
; it gives you all distinct records:
ViewsLog.group(:unit_id)
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