我在应用程序中有以下状态机:
class Cv < ActiveRecord::Base
include Workflow
workflow do
state :new do
event :submit, :transitions_to => :awaiting_review
end
state :awaiting_review do
event :review, :transitions_to => :being_reviewed
end
state :being_reviewed do
event :accept, :transitions_to => :accepted
event :reject, :transitions_to => :rejected
end
state :accepted
state :rejected
end
def submit
halt unless valid?
end
end
# cvs_controller.rb
def update
@cv = Cv.find(params[:id])
if @cv.update_attributes(params[:cv])
# @cv.back_to_review!
redirect_to root_path
end
end
我希望awaiting_review
在更新对象后始终将状态移动到。
那么我应该在每个状态块中添加event :back_to_review!, :transitions_to => :awaiting_reviewed
吗?
我正在使用这个宝石:https ://github.com/geekq/workflow