我有集合(simple_form)的“视图”输入,但该集合应该在模型中。
我必须在模型中声明一个包含 ["Brother", "Daughter", "Father", "Friend", "Husband", "Mother", "Sister", "Son", "Wife"] 的变量并用于在这里查看:
= f.input :relationship
这就是我的观点:
= simple_form_for @emergency_information, html: {class: 'form-horizontal' } do |f|
= f.error_notification
= f.input :name
= f.input :relationship, collection: ["Brother", "Daughter", "Father", "Friend", "Husband", "Mother", "Sister", "Son", "Wife"]
那是我的模特
class EmergencyInformation < ActiveRecord::Base
belongs_to :user
validates :user_id, :name, presence: true
end
请帮帮我!