Created
October 31, 2017 13:09
-
-
Save bdubaut/1bd988d039101e45123f644aaac134c9 to your computer and use it in GitHub Desktop.
Sequel tips & tricks
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
# Selecting only column values instead of the whole table | |
# One column | |
MyObject.select_map(:column_name) # > [value1, value2, ...] | |
# Multiple columns | |
MyObject.select_map([:column1, :column2]) # > [[value1, value2], [value 3, value4], ...] | |
# And you can have `.where` statements before | |
MyObject.where(something: true).select_map(:column_name) # > [value1, value2, ...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment