Exception: ActiveRecord::UnknownPrimaryKey

Inherits:
ActiveRecordError show all
Defined in:
activerecord/lib/active_record/errors.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ UnknownPrimaryKey

Returns a new instance of UnknownPrimaryKey.



177
178
179
# File 'activerecord/lib/active_record/errors.rb', line 177

def initialize(model)
  @model = model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model



175
176
177
# File 'activerecord/lib/active_record/errors.rb', line 175

def model
  @model
end

Instance Method Details

#messageObject



181
182
183
# File 'activerecord/lib/active_record/errors.rb', line 181

def message
  "Unknown primary key for table #{model.table_name} in model #{model}."
end