Last active
February 25, 2016 15:44
-
-
Save sapereau83/b532e3f95d572422caeb to your computer and use it in GitHub Desktop.
Select a specific attribute of the first and last record in an ActiveRecord Model
This file contains hidden or 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
| # Example: | |
| # | |
| # A Product Model with a :name attribute | |
| first, last = Product.pluck(:name).values_at(0, Product.count - 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment