Human_name for state in ruby ​​gem state_machine

I am using gem state_machine - Official

Each state can have a "human name". In the docs and APIs I tried:

in my_model.rb

state_machine :initial => :new do state :new, :human_name => 'Added and not accepted' ... 

in my_view.haml

 %p= MyModel.human_state_name(@item.state_name) %p= @item.human_state_name 

both options return only "new" instead of "Added and not accepted." What should I do? Am I mistaken in setting up a person’s name or in getting a person’s name?

Update Works in:

 en: activerecord: state_machines: mymodel: # model name states: new: 'Added and not accepted' # state name 
+7
source share
1 answer

You do not need to pass: man_name is an option for a state machine. Just define a translation for your language:

 en: activerecord: state_machines: mymodel: # model name state: # state name states: new: 'Added and not accepted' events: # you can also define translations for the events some_event: 'put custom translation here' 
+9
source

All Articles