Rails not rolling back transaction after failed save()
问题 I have this domain model: A user has group of items, and the state of the items can fail a validation. Validation works fine, and I even see exceptions get called when I use save! . In my controller, I have this: @user.items() << item if @user.save render :json => {}, :status => :ok else render :json => {:status => :error, :errors => item.errors}, :status => :bad_request end The first POST succeeds, and the second POST fails, but when I hit the index, I still see two objects, as if the second