次のコードを含むモデルがあります。
appraisal_detail.each_value { |detail|
# some code...
}
「undefined method 'each_value'」というメッセージで NoMethodError が発生しています。私は何か間違ったことをしていますか?どんな提案でも大歓迎です。
エラーが発生するメソッドの完全な内容は次のとおりです。
def self.update_appraisal_details(appraisal, appraisal_detail)
status = true
appraisal_detail_ids = appraisal.employee_appraisal_detail_ids
appraisal_detail.each_value { |detail|
appraisal_detail = find_by_employee_appraisal_id_and_kra_list_id(appraisal.id, detail[:kra_list_id])
if appraisal_detail.nil? # For newly added KRA
new_detail = EmployeeAppraisalDetail.new(detail.merge({:employee_appraisal_id => appraisal.id}))
status = (new_detail.save && status)
elsif appraisal_detail.status == "Inactive"
status = (appraisal_detail.update_attributes(:status => "Active") && status)
appraisal_detail_ids.delete(appraisal_detail.id)
else
appraisal_detail_ids.delete(appraisal_detail.id)
end
}
end