加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 交易中的Rails交易?

发布时间:2020-12-17 03:06:14 所属栏目:百科 来源:网络整理
导读:当您与交易进行交易时会发生什么 def a ActiveRecord::Base.transaction do # stuff endendActiveRecord::Base.transaction do a # more stuffend 如果内部事务成功但外部事务失败,反之亦然会发生什么?当成功或失败时会发生什么? 解决方法 transaction cal
当您与交易进行交易时会发生什么

def a
  ActiveRecord::Base.transaction do
    # stuff
  end
end

ActiveRecord::Base.transaction do
  a
  # more stuff
end

如果内部事务成功但外部事务失败,反之亦然会发生什么?当成功或失败时会发生什么?

解决方法

transaction calls can be nested. By default,this makes all database statements in the nested transaction block become part of the parent transaction.

该行为在documentation中有详细描述

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读