开发者

Translate form helper to simple_form or formstatic

开发者 https://www.devze.com 2023-03-18 06:30 出处:网络
I have this in my model: class Person < ActiveRecord::Base RELATIONSHIP_STATUSES = [ \"single\", \"in a relationship\",

I have this in my model:

class Person < ActiveRecord::Base
  RELATIONSHIP_STATUSES = [
    "single",
    "in a relationship",
    "together",
    "it's complicated"
  ]

  validates :relationship_status, :inclusion => RELATIONSHIP_STATUSES
end

This in the view:

collection_select(:pers开发者_开发技巧on, :relationship_status, Person::RELATIONSHIP_STATUSES, :to_s)

And I would like to translate that to simple_form. Is that possible?


If I understood you right, it's simple(it's for formtastic):

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

精彩评论

暂无评论...
验证码 换一张
取 消