Last active
May 18, 2019 01:06
-
-
Save lettergram/35ed869e64fdfa7030f0ca0ade025782 to your computer and use it in GitHub Desktop.
Create a subquery in Rails using Active Record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = select(:author, :created_at) | |
.from( | |
where("created_at >= ?", Date.today - 6.months) | |
.order(created_at: :desc) | |
.limit(100) | |
).order(author: :asc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment