2011-07-09 27 views
1

我有这个在我的模型:翻译形式帮手simple_form或formstatic

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

如果我理解你的权利,这是简单的(它是formtastic):

<%= form.input :relationship_status, :as => :select, :collection => Person::RELATIONSHIP_STATUSES %> 
+0

你不需要的:作为选择,如果你想使用的选择集 – rafaelfranca