instance method
references
Ruby on Rails 3.1.12
Since v2.2.3Signature
references(*args)
Adds a reference. Optionally adds a type column, if :polymorphic option is provided. references and belongs_to are acceptable.
Examples
t.references(:goat) t.references(:goat, :polymorphic => true) t.belongs_to(:goat)
Parameters
-
argsrest
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 421
def references(*args)
options = args.extract_options!
polymorphic = options.delete(:polymorphic)
args.each do |col|
@base.add_column(@table_name, "#{col}_id", :integer, options)
@base.add_column(@table_name, "#{col}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) unless polymorphic.nil?
end
end
Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb line 421
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::Table