Tag: 动态表单

使用has_many通过动态表单rails 4

我想用动态表格创建一个约会表格。 但我没有得到我做错的事 我在使用部分_appointment_record_form_fields和使用了appointment_controller时遇到了麻烦。 有人可以帮我修复控制器和视图吗? 我的模特: class Appointment < ActiveRecord::Base has_many :appointment_record_forms, dependent: :destroy has_many :record_forms, through: :appointment_record_forms accepts_nested_attributes_for :appointment_record_forms, allow_destroy: true end class AppointmentRecordForm < ActiveRecord::Base belongs_to :appointment belongs_to :record_form serialize :properties, Hash def validate_properties record_form.record_form_fields.each do |record_form_field| if record_form_field.required? && properties[record_form_field.name].blank? errors.add record_form_field.name, "must not be blank" end end end end class RecordForm < […]