状态计算机ruby gem中状态的人名

状态计算机ruby gem中状态的人名,ruby,ruby-on-rails-3,Ruby,Ruby On Rails 3,我使用gem state_机器- 每个州都可以有“人名”。通过我尝试过的文档和API: 在my_model.rb中 state_machine :initial => :new do state :new, :human_name => 'Added and not accepted' ... 在我看来 %p= MyModel.human_state_name(@item.state_name) %p= @item.human_state_name 两个变体都只返

我使用gem state_机器-

每个州都可以有“人名”。通过我尝试过的文档和API:

在my_model.rb中

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

%p= MyModel.human_state_name(@item.state_name)
%p= @item.human_state_name
两个变体都只返回“new”,而不是“Added and not accepted”。我该怎么办?我在设置人名或获取人名时出错了

更新 工作地点:

en:
  activerecord:
    state_machines:
      mymodel: # model name
        states:
          new: 'Added and not accepted' # state name

您不需要将:human\u name选项传递给状态机。只需为您的语言定义翻译:

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'

使用其他语法=)非常感谢@dmr您是否愿意分享其他有效的语法?我也有同样的问题,如果你想让州多元化,翻译就不起作用。