I use gem state_machine - Official
Each state can have 'human name'. By docs and APIs i've 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 variants return just 'new' instead of 'Added and not accepted'. What I should do? I've made mistake in setting human_name or in getting human_name?
Update Works in:
en:
activerecord:
state_machines:
mymodel: # model name
states:
new: 'Added and not accepted' # state name
You don't need to pass :human_name option to state machine. Just define translations 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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With