在模型中调用了两次的accepts_nested_attributes_for

时间:2011-03-02 17:33:04

标签: ruby-on-rails

class StepQuiz < ActiveRecord::Base
  belongs_to :step
  has_many :step_quiz_questions, :dependent => :destroy

  accepts_nested_attributes_for :step
  accepts_nested_attributes_for :step_quiz_questions, :allow_destroy => true
  attr_accessible :step_id, :instructions, :correct_to_pass, :retakes_allowed, :time_limit, :step_attributes, :step_quiz_questions_attributes
end

我是否允许对给定模型调用两次accepts_nested_attributes_for。它似乎没有错误。

1 个答案:

答案 0 :(得分:0)

您正在使用此处定义的类方法:http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html

答案是肯定的,这样你就可以调整每一个案例。