【发布时间】:2019-11-05 15:17:29
【问题描述】:
我正在使用事务块并在块内进行一些操作,有些事情应该忽略事务块,我无法从事务块中移动更新,因为它与代码紧密耦合。
我们怎样才能跳过某些部分,让其余的行为像往常一样
Record.transaction do
check_for_errors required_columns
create_report
end
def check_for_errors
loop
...
begin
Methods
// want to skip this perticular db update from transaction block
job.update_column(total_number: loop index)
// as this is under transaction block no changes can be seen on ui
rescue => e
populate_error_message(e.message)
raise ActiveRecord::Rollback
end
end
end
知道在这种情况下可以做什么吗?
【问题讨论】:
-
你使用什么数据库?
标签: ruby-on-rails ruby ruby-on-rails-4