method
references
v4.0.2 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::TableDefinition
references(*args)public
No documentation available.
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 253
def references(*args)
options = args.extract_options!
polymorphic = options.delete(:polymorphic)
index_options = options.delete(:index)
args.each do |col|
column("#{col}_id", :integer, options)
column("#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) if polymorphic
index(polymorphic ? %(id type).map { |t| "#{col}_#{t}" } : "#{col}_id", index_options.is_a?(Hash) ? index_options : {}) if index_options
end
end 1Note
See column
See the end part of the docs on column for example uses.