refactor self.class to a variable

This commit is contained in:
Aaron Patterson
2010-12-02 14:38:33 -08:00
parent ae35a36afc
commit 9f0133fbf4

View File

@@ -250,7 +250,8 @@ module ActiveRecord
def update(attribute_names = @attributes.keys)
attributes_with_values = arel_attributes_values(false, false, attribute_names)
return 0 if attributes_with_values.empty?
self.class.unscoped.where(self.class.arel_table[self.class.primary_key].eq(id)).arel.update(attributes_with_values)
klass = self.class
klass.unscoped.where(klass.arel_table[klass.primary_key].eq(id)).arel.update(attributes_with_values)
end
# Creates a record with values matching those of the instance attributes