Skip to content

Instantly share code, notes, and snippets.

@bdubaut
Created October 31, 2017 13:09
Show Gist options
  • Save bdubaut/1bd988d039101e45123f644aaac134c9 to your computer and use it in GitHub Desktop.
Save bdubaut/1bd988d039101e45123f644aaac134c9 to your computer and use it in GitHub Desktop.
Sequel tips & tricks
# 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