Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Created May 22, 2013 09:17
Show Gist options
  • Save rummelonp/5626299 to your computer and use it in GitHub Desktop.
Save rummelonp/5626299 to your computer and use it in GitHub Desktop.
ActiveRecord::Base 継承したクラスの index 一覧とかカラム名から含まれる index 一覧取るやつ
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