Update in transactions

Can i update attributes in transaction… I mean while saving a record i
do like this:-

object = Model.new(params[:model])
Model.transaction do
object.save!
end

Can we also do it for updating a record… i mean like this:-

object = Model.find(:id)
Model.transaction do
object.update_attributes!
end

Obviously this chunk of code is not working, thats why i asked you
people…

Thanks in advance

On Mar 2, 2:30 pm, Hemant B. [email protected] wrote:

object = Model.find(:id)
Model.transaction do
object.update_attributes!
end

Obviously this chunk of code is not working, thats why i asked you
people…

Other than the fact that you’re passing an invalid argument to find
and that update_attributes probably requires you to pass an argument
this should be fine (although obviously pointless unless you make
several changes within the transaction.

Fred