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