我使用工作流作为状态机。我想在每次更新后将状态移动到,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)