ActiveRecord::AssociationTypeMismatch

class ActiveRecord::AssociationTypeMismatch

Parent:
ActiveRecord::ActiveRecordError

Raised when an object assigned to an association has an incorrect type.

class Ticket < ActiveRecord::Base
  has_many :patches
end

class Patch < ActiveRecord::Base
  belongs_to :ticket
end

# Comments are not patches, this assignment raises AssociationTypeMismatch.
@ticket.patches << Comment.new(content: "Please attach tests to your patch.")

© 2004–2017 David Heinemeier Hansson
Licensed under the MIT License.

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部