私は、AASM
gem を使用して特定のオブジェクトをさまざまな状態に遷移させる Rails アプリに取り組んでいます。
「承認済み」の属性が false に設定されている場合のみ、「事前承認」の初期状態が必要です。AASM
gemを使用して自動トランジションを行う方法はありますか?
状態は次のとおりです。
aasm column: :status do
state :pre_approval, initial: true
state :pending
state :opened
state :closed
event :approved do
transitions from: :pre_approval, to: :pending, guard: :approved_changed?
end
event :received, after: Proc.new { set_received_date } do
transitions from: :pending, to: :opened
end
event :complete, after: Proc.new { set_completion_date } do
transitions from: :opened, to: :closed
end
end