Skip to content

Instantly share code, notes, and snippets.

@gregoriokusowski
Created March 11, 2011 10:54
Show Gist options
  • Save gregoriokusowski/865725 to your computer and use it in GitHub Desktop.
Save gregoriokusowski/865725 to your computer and use it in GitHub Desktop.
Method that searches an ActiveRecord::Base for it's columns by type.
#clazz must be the ActiveRecord::Base, and type must be a type symbol
def find_columns(clazz, type)
clazz.columns.select do |c|
c.type == type
end.collect do |c|
c.name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment