我的模型中有这个:
class Person < ActiveRecord::Base
RELATIONSHIP_STATUSES = [
"single",
"in a relationship",
"together",
"it's complicated"
]
validates :relationship_status, :inclusion => RELATIONSHIP_STATUSES
end
在视图中:
collection_select(:person, :relationship_status, Person::RELATIONSHIP_STATUSES, :to_s)
我想将其转换为simple_form。这可能吗?
答案 0 :(得分:0)
如果我理解你的话,这很简单(适用于formtastic
):
<%= form.input :relationship_status, :as => :select, :collection => Person::RELATIONSHIP_STATUSES %>