method
new
v6.1.7.7 -
Show latest stable
-
0 notes -
Class: MismatchedForeignKey
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
new( message: nil, sql: nil, binds: nil, table: nil, foreign_key: nil, target_table: nil, primary_key: nil, primary_key_column: nil )
public
Hide source
# File activerecord/lib/active_record/errors.rb, line 150 def initialize( 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 = <<~EOM.squish 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}`). EOM else msg = <<~EOM.squish 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. EOM end if message msg << "\nOriginal message: #{message}" end super(msg, sql: sql, binds: binds) end