undefined method on ActiveRecord::Relation object
问题 the following code fieldvalue = Admin::FieldValue.where(:item_id => @admin_item.id, :field_id => key) fieldvalue.update_attributes(:value => value) raise the following error NoMethodError (undefined method `update_attributes' for #<ActiveRecord::Relation:0x00000102dfc868>): why is it a Relation object and not a FieldValue object, what's the right way to manage this 回答1: fieldvalue should return only one value? fieldvalue = Admin::FieldValue.where(:item_id => @admin_item.id, :field_id => key)