0
我使用pluginaweek/state_machine寶石 我需要驗證對象從用戶提交表單來驗證對象,但只有過渡到一定前州。其他州不需要驗證。從狀態機的形式來PARAMS轉換之前某些國家
我有:
class Invoice < ActiveRecord::Base
state_machine :state, :initial => :draft do
before_transition :draft => :emited, :do => :check_date
state :emited
state :draft
end
def check_date
if params[:date] < Time.now
false
end
end
end
但PARAMS哈希不在型號。有辦法做我需要的嗎?