1

我的模型中有这个:

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。那可能吗?

4

1 回答 1

0

如果我理解你的话,这很简单(它是为了formtastic):

<%= form.input :relationship_status, :as => :select, :collection => Person::RELATIONSHIP_STATUSES %>
于 2011-07-09T16:08:07.793 回答