我有这样的模式:轨道4嵌套的验证工作不
class CompetitionEntry < ActiveRecord::Base
has_many :participants
has_one :address
has_many :music_programs
accepts_nested_attributes_for :address
accepts_nested_attributes_for :participants, :music_programs,
:allow_destroy => true,
:reject_if => :all_blank
end
这一个:
class Participant < ActiveRecord::Base
belongs_to :competition_entry
has_one :birthplace
validates :name, :surname, :instrument, presence: true
end
现在的问题是,如果我创建一个新的参赛作品,它经历。 但是,如果我填入一个字段,即名称,那么它会出现一个错误!
这是怎么发生的?当所有都是空的时候它应该失败!
什么是错误? – Agis