跳至内容 跳至搜索

当属性未定义时引发。

class User < ActiveRecord::Base
  has_many :pets
end

user = User.first
user.pets.select(:id).first.user_id
# => ActiveModel::MissingAttributeError: missing attribute 'user_id' for Pet