Skip to content

Instantly share code, notes, and snippets.

@etozzato
Created August 4, 2010 00:49
Show Gist options
  • Save etozzato/507464 to your computer and use it in GitHub Desktop.
Save etozzato/507464 to your computer and use it in GitHub Desktop.
module Indexes
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def indexes
@indexes ||= ActiveRecord::Base.connection.indexes(table_name).map(&:name)
end
end
end
ActiveRecord::Base.send(:include, Indexes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment