method

update

rails latest stable - Class: ActiveRecord::Relation
update(id = :all, attributes)
public

No documentation available.

# File activerecord/lib/active_record/relation.rb, line 533
    def update(id = :all, attributes) # :nodoc:
      if id == :all
        each { |record| record.update(attributes) }
      else
        klass.update(id, attributes)
      end
    end

2Notes

Multiple update, on query ?

zimbatm · Jul 27, 2011
Person.update(people.keys, people.values)

Will this request issue one or multiple queries to update the table data (as in http://stackoverflow.com/questions/3432/multiple-updates-in-mysql#3466 )

The answer is: it will do TWO queries per updated row. One select and one update.

Beware: virtual attributes are ignored

zubin · Nov 30, 2012

Even though validations are called, virtual attributes are ignored.