我正在开发一个使用AASM
gem 将特定对象转换为不同状态的 Rails 应用程序。
需要具有“预先批准”的初始状态,但前提是“已接受”属性设置为假。有没有办法使用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