transaction not working with update_attributes!

I am trying to wrap the updating of two models in a transaction and when the transaction fails it is not rolling back.

My method is :

  def update_attributes(user,params)     @user = user     @company = user.company     begin       User.transaction do         @user.update_attributes!(params[:user])         @company.update_attributes!(params[:company])       end       true     rescue       false     end

  end

In the above method , if @user fails @company will not be saved but not vice versa. My question is am I using transactions correctly and if so what am I doing wrong?

thanks James

I am trying to wrap the updating of two models in a transaction and when the transaction fails it is not rolling back.

Does activerecord try to do a rollback (check the logs) ? Are you using a database that supports transaction (ie not mysql with myisam tables)?

Fred