Skip to content

Instantly share code, notes, and snippets.

@sapereau83
Last active February 25, 2016 15:44
Show Gist options
  • Select an option

  • Save sapereau83/b532e3f95d572422caeb to your computer and use it in GitHub Desktop.

Select an option

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
# 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