Exception: ActiveRecord::CompositePrimaryKeyMismatchError

Inherits:
ActiveRecordError
  • Object
show all
Defined in:
lib/active_record/associations/errors.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reflection = nil) ⇒ CompositePrimaryKeyMismatchError

Returns a new instance of CompositePrimaryKeyMismatchError.



190
191
192
193
194
195
196
197
198
199
200
# File 'lib/active_record/associations/errors.rb', line 190

def initialize(reflection = nil)
  if reflection
    if reflection.has_one? || reflection.collection?
      super("Association #{reflection.active_record}##{reflection.name} primary key #{reflection.active_record_primary_key} doesn't match with foreign key #{reflection.foreign_key}. Please specify query_constraints, or primary_key and foreign_key values.")
    else
      super("Association #{reflection.active_record}##{reflection.name} primary key #{reflection.association_primary_key} doesn't match with foreign key #{reflection.foreign_key}. Please specify query_constraints, or primary_key and foreign_key values.")
    end
  else
    super("Association primary key doesn't match with foreign key.")
  end
end

Instance Attribute Details

#reflectionObject (readonly)

Returns the value of attribute reflection.



188
189
190
# File 'lib/active_record/associations/errors.rb', line 188

def reflection
  @reflection
end