Update_all along with conditions, validations and callbacks

hi,
I want to update the database given a where clause. Basically i want a
function like ActiveRecord::base.update_attributes along with a
parameter for condition.

http://www.railsbrain.com/api/rails-1.2.6/doc/index.html?a=M001518&name=update_attributes

Currently as far as i can tell only update_all has a where clause but
it does not respect callbacks or validations. I can enclose the
update_attributes statement in a if clause, but then it is possible
that i have loaded a stale object. Also is it possible to get the
update_count and not the updated object.

eg :
if obj.status == ā€˜Pā€™
obj.update_attributes(:status => ā€˜Dā€™, :amount => 100)
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs