Created
May 22, 2013 09:17
-
-
Save rummelonp/5626299 to your computer and use it in GitHub Desktop.
ActiveRecord::Base 継承したクラスの index 一覧とかカラム名から含まれる index 一覧取るやつ
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
class ActiveRecord::Base | |
def self.indexes | |
connection.indexes(table_name) | |
end | |
def self.indexes_by_column(column_name) | |
indexes.select { |i| i.columns.include?(column_name.to_s) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment