Exception: ActiveRecord::UnknownPrimaryKey

Inherits:
ActiveRecordError show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/errors.rb

Overview

Raised when a primary key is needed, but not specified in the schema or model.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model = nil, description = nil) ⇒ UnknownPrimaryKey

Returns a new instance of UnknownPrimaryKey.



378
379
380
381
382
383
384
385
386
387
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/errors.rb', line 378

def initialize(model = nil, description = nil)
  if model
    message = "Unknown primary key for table #{model.table_name} in model #{model}."
    message += "\n#{description}" if description
    @model = model
    super(message)
  else
    super("Unknown primary key.")
  end
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



376
377
378
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/errors.rb', line 376

def model
  @model
end