state-machines / state_machines

Adds support for creating state machines for attributes on any Ruby class
https://github.com/state-machines/state_machines
MIT License
814 stars 91 forks source link

Unable to obtain status from database #93

Closed QQDengWangF closed 1 year ago

QQDengWangF commented 1 year ago

I created a project using state Machine, the state obtained when preparing to retrieve the state from the database and return it to the front-end is nil. The state field in the database has values, and the following is my definition of the state machine:

state_machine initial: :leader_pending do
    state :leader_pending, :value => 1
    state :it_pending, :value => 2
    state :user_pending, :value => 3
    state :manager_pending, :value => 4
    state :finance_pending, :value => 5

    event :leader_to_process do
        transition :leader_pending => :it_pending
    end

    event :it_to_process do
        transition :it_pending => :user_pending 
    end

    event :user_to_process do
        transition :user_pending => :manager_pending
    end

    event :user_return_process do
        transition :user_pending => :it_pending
    end

    event :manager_to_process do
        transition :manager_pending => :finance_pending
    end

end

QQDengWangF commented 1 year ago

Sorry, I forgot to reference state_ machines-activerecord