【发布时间】:2010-12-03 22:59:36
【问题描述】:
我正在关注Nested Model Form Part 1。
但我有一个问题。
如果我添加validates_presence_of :answers:
class Question < ActiveRecord::Base
belongs_to :survey
validates_presence_of :answers
has_many :answers, :dependent => :destroy
accepts_nested_attributes_for :answers,
:reject_if => lambda { |a| a[:content].blank? },
:allow_destroy => true
end
_destroy 跳过问题模型验证。所以我可以用空答案更新问题模型。
我可能做错了。我该如何解决?
提前致谢。
【问题讨论】:
标签: ruby-on-rails nested-forms