Module: BigintPrimarykey::DefaultBigintForeignKeyReferences

Defined in:
lib/bigint_primarykey.rb

Instance Method Summary collapse

Instance Method Details

#references(*args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bigint_primarykey.rb', line 36

def references(*args)
  options = args.extract_options!
  options.reverse_merge! limit: 8
  # Limit shouldn't affect "#{col}_type" column in polymorphic reference.
  # But don't change value if it isn't simple 'true'.
  # Examples:
  #   t.references :subject, null: false, polymorphic: true ==> t.integer :subject_id, limit: 8, null: false
  #                                                             t.string  :subject_type, null: false
  #   t.references :subject, polymorphic: { limit: 120 }    ==> t.integer :subject_id, limit: 8
  #                                                             t.string  :subject_type, limit: 120
  options[:polymorphic] = options.except(:polymorphic, :limit) if options[:polymorphic] == true
  super(*args, options)
end