Module: SchemaPlus::ForeignKeys::ActiveRecord::Base::ClassMethods

Defined in:
lib/schema_plus/foreign_keys/active_record/base.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#foreign_keysObject

Returns a list of ForeignKeyDefinition objects, for each foreign key constraint defined in this model's table

(memoized result gets reset in Middleware::Model::ResetColumnInformation)


16
17
18
# File 'lib/schema_plus/foreign_keys/active_record/base.rb', line 16

def foreign_keys
  @foreign_keys ||= connection.foreign_keys(table_name, "#{name} Foreign Keys")
end

#reset_foreign_key_informationObject


20
21
22
# File 'lib/schema_plus/foreign_keys/active_record/base.rb', line 20

def reset_foreign_key_information
  @foreign_keys = @reverse_foreign_keys = nil
end

#reverse_foreign_keysObject

Returns a list of ForeignKeyDefinition objects, for each foreign key constraint of other tables that refer to this model's table


26
27
28
# File 'lib/schema_plus/foreign_keys/active_record/base.rb', line 26

def reverse_foreign_keys
  @reverse_foreign_keys ||= connection.reverse_foreign_keys(table_name, "#{name} Reverse Foreign Keys")
end