0

我正在使用红宝石 AASM 宝石。

有谁知道跳过状态的正确方法是什么?

class Job
  # ...

  event :stage1_completed do
    if stage2_completed?
      transitions from: :stage1, :to => :stage3
    else
      transitions from: :stage1, :to => :stage2
    end
  end

  # ...
end

在 AASM 中进行设置的最佳方法是什么?

我在一组 resque 作业中使用此代码,因此 stage1 是一个 resque 作业,然后更新状态并开始完成下一个 resque 作业。阶段2相同,然后阶段3

4

1 回答 1

1

你可以使用guards.

event :stage1_completed do
    transitions from: :stage1, :to => :stage3, :guard => :stage2_completed? 
end
于 2014-10-07T18:26:53.177 回答