@@ -180,7 +180,7 @@ def update_attribute(name, value)
180
180
name = name . to_s
181
181
verify_readonly_attribute ( name )
182
182
send ( "#{ name } =" , value )
183
- save ( : validate => false )
183
+ save ( validate : false )
184
184
end
185
185
186
186
# Updates the attributes of the model from the passed-in hash and saves the
@@ -235,8 +235,8 @@ def update_columns(attributes)
235
235
236
236
updated_count = self . class . where ( self . class . primary_key => id ) . update_all ( attributes )
237
237
238
- attributes . each do |k , v |
239
- raw_write_attribute ( k , v )
238
+ attributes . each do |k , v |
239
+ raw_write_attribute ( k , v )
240
240
end
241
241
242
242
updated_count == 1
@@ -388,10 +388,14 @@ def create_or_update
388
388
# Returns the number of affected rows.
389
389
def update ( attribute_names = @attributes . keys )
390
390
attributes_with_values = arel_attributes_with_values_for_update ( attribute_names )
391
- return 0 if attributes_with_values . empty?
392
- klass = self . class
393
- stmt = klass . unscoped . where ( klass . arel_table [ klass . primary_key ] . eq ( id ) ) . arel . compile_update ( attributes_with_values )
394
- klass . connection . update stmt
391
+
392
+ if attributes_with_values . empty?
393
+ 0
394
+ else
395
+ klass = self . class
396
+ stmt = klass . unscoped . where ( klass . arel_table [ klass . primary_key ] . eq ( id ) ) . arel . compile_update ( attributes_with_values )
397
+ klass . connection . update stmt
398
+ end
395
399
end
396
400
397
401
# Creates a record with values matching those of the instance attributes
0 commit comments