instance method
update
Ruby on Rails 2.3.18
Since v2.2.3 Last seen in v2.3.18 PrivateAvailable in: v2.2.3 v2.3.18
Signature
update(attribute_names = @attributes.keys)
Updates the associated record with values matching those of the instance attributes. Returns the number of affected rows.
Parameters
-
attribute_namesopt = @attributes.keys
Source
# File activerecord/lib/active_record/base.rb, line 2941
def update(attribute_names = @attributes.keys)
quoted_attributes = attributes_with_quotes(false, false, attribute_names)
return 0 if quoted_attributes.empty?
connection.update(
"UPDATE #{self.class.quoted_table_name} " +
"SET #{quoted_comma_pair_list(connection, quoted_attributes)} " +
"WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quote_value(id)}",
"#{self.class.name} Update"
)
end
Defined in activerecord/lib/active_record/base.rb line 2941
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Base