method

new

Importance_0
v5.1.7 - Show latest stable - 0 notes - Class: MismatchedForeignKey
new( adapter = nil, message: nil, sql: nil, binds: nil, table: nil, foreign_key: nil, target_table: nil, primary_key: nil, primary_key_column: nil ) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/errors.rb, line 118
    def initialize(
      adapter = nil,
      message: nil,
      sql: nil,
      binds: nil,
      table: nil,
      foreign_key: nil,
      target_table: nil,
      primary_key: nil,
      primary_key_column: nil
    )
      if table
        type = primary_key_column.bigint? ? :bigint : primary_key_column.type
        msg =           Column `#{foreign_key}` on table `#{table}` does not match column `#{primary_key}` on `#{target_table}`,          which has type `#{primary_key_column.sql_type}`.          To resolve this issue, change the type of the `#{foreign_key}` column on `#{table}` to be :#{type}.          (For example `t.#{type} :#{foreign_key}`)..squish
      else
        msg =           There is a mismatch between the foreign key and primary key column types.          Verify that the foreign key column type and the primary key of the associated table match types..squish
      end
      if message
        msg << "\nOriginal message: #{message}"
      end
      super(msg)
    end
Register or log in to add new notes.