Skip to content

Instantly share code, notes, and snippets.

@lappi-lynx
Created June 11, 2013 16:43
Show Gist options
  • Save lappi-lynx/5758489 to your computer and use it in GitHub Desktop.
Save lappi-lynx/5758489 to your computer and use it in GitHub Desktop.
Rails group_by_day method
# Method for grouping users by the day (for postgresql):
User.order("DATE(created_at)").group("DATE(created_at)").count
@fjfish
Copy link

fjfish commented Mar 10, 2025

You don't need the order clause as active record will send this as SQL and that will sort all that for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment