我有一个问题模型:
class Problem < ActiveRecord::Base
classy_enum_attr :state, default: ->(enum) { enum.min }
end
Enum Class
class State < ClassyEnum::Base
def description
fail 'Unimplemented'
end
end
class State::Open < State
def description
'We are working, or will soon be working on this problem'
end
end
class State::CustomerUpdate < State
def description
'We are waiting information from you'
end
end
端
我希望能够对状态进行内联编辑并拥有best_in_place gem。
show.html.erb看起来像:
<%= best_in_place @problem, :state, type: :select, place_holder: @problem.state.to_s.humanize, :collection => State.select_options%>
我的问题是下拉列表如下:
open
customer_update
但我希望它显示为:
Open
Customer Update
State.select_options
返回
[["Open", "open"], ["Customer Update", "customer_update"]]
如何显示每个枚举的第一部分而不是第二部分?
谢谢