Created
March 11, 2011 10:54
-
-
Save gregoriokusowski/865725 to your computer and use it in GitHub Desktop.
Method that searches an ActiveRecord::Base for it's columns by type.
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
#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