Skip to content

Instantly share code, notes, and snippets.

@kirkelifson
Created July 10, 2016 14:40
Show Gist options
  • Save kirkelifson/da85df4b9e9878208dac1ca744be9e71 to your computer and use it in GitHub Desktop.
Save kirkelifson/da85df4b9e9878208dac1ca744be9e71 to your computer and use it in GitHub Desktop.
Selects all column names containing phone and not containing type
phones = Model.attribute_names.select { |c| c.include? 'phone' }.reject { |c| c.include? 'type' }.map(&:to_sym)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment