将state_machine Gem中的默认“状态”字段更改为自定义

时间:2019-11-07 09:26:25

标签: ruby-on-rails

我正在其中一个Rails应用程序中使用StateMachine Gem。在我开始使用StateMachine之前,我的模型有一个名为:state(国家/地区的州)的字段。随着StateMachine在:state上初始化。 我的模型显示冲突且不允许保存。 有什么办法可以更改默认字段的名称以初始化StateMachine

类似

state_machine initial: :scheduled, *field :custom_state* do
  # state details
end

谢谢。

1 个答案:

答案 0 :(得分:0)

因此,经过长时间的搜索/实验后,我认为您可以轻松完成

state_machine initial: :scheduled, attribute: :<yourField> do
  # state details
end