0
我正在使用工作流作爲狀態機。我想在每次更新之後移動狀態到awaiting_review
但我也有current_sign_in_at
屬性用戶登錄後他的狀態改爲awaiting_review
如何避免這種情況?如何在更新更新對象時更改狀態時不包含時間戳?
before_save :needs_review, on: :update
# before_save
def needs_review
self.state = 'awaiting_review' unless state_changed?
end
workflow do
state :awaiting_review do
event :accept, :transitions_to => :accepted
event :reject, :transitions_to => :rejected
end
state :accepted do
event :reject, :transitions_to => :rejected
end
state :rejected
end
# sign_in_count :integer default(0)
# current_sign_in_at :datetime
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
哪些領域應該更新觸發狀態變化?你可以使用'changed'方法來特別檢測那些。 – bdares 2013-02-14 19:56:35
除了這些,我在評論中提到的所有fiels:[sign_in_count ..] – tomekfranek 2013-02-14 22:29:04