title: Nested associations failing on save
body: <p>Trying to set up nested associations ( with <code>accepts_nested_attributes_for</code> ) in Rails 3, but <code>save</code> is failing without showing any errors on the model.</p>
  
  <p><code>db/schema.rb</code>:</p>
  
  <pre><code>create_table "question_responses", :force =&gt; true do |t|
    t.string   "answer"
    t.boolean  "correct"
    t.integer  "question_id"
    t.integer  "quiz_result_id"
  end
  
  create_table "quiz_results", :force =&gt; true do |t|
    t.integer  "student_id"
    t.integer  "quiz_id"
    t.text     "message"
  end
  </code></pre>
  
  <p><code>question_response.rb</code>:</p>
  
  <pre><code>class QuestionResponse &lt; ActiveRecord::Base
  
    belongs_to :question
    belongs_to :quiz_result, :inverse_of =&gt; :question_responses
  
    validates :question, :presence =&gt; true
    validates :quiz_result, :presence =&gt; true
  
    before_save :check_answer
  end
  </code></pre>
  
  <p><code>quiz_result.rb</code>:</p>
  
  <pre><code>class QuizResult &lt; ActiveRecord::Base
  
    validates :quiz, :presence =&gt; true
    validates :student, :presence =&gt; true
    validates :quiz_id, :uniqueness =&gt; { :scope =&gt; :student_id }
    validate :student_teacher
  
    belongs_to :quiz
    belongs_to :student
    has_many :question_responses, :dependent =&gt; :destroy, :inverse_of =&gt; :quiz_result
    accepts_nested_attributes_for :question_responses
  
  end
  </code></pre>
  
  <p>Any suggestions for how I can get this working?</p>
  
  <p>server output:</p>
  
  <pre><code>Started POST "/quiz_results" for 127.0.0.1 at 2012-03-20 10:20:24 +0000
  Processing by QuizResultsController#create as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"YceTVCh/GxdReb3KRMNj+cJhm6k0jwhsHl3LcJlSDJM=", "quiz_result"=&gt;{"student_id"=&gt;"695735877", "quiz_id"=&gt;"17663260", "question_responses_attributes"=&gt;{"0"=&gt;{"question_id"=&gt;"14376743", "answer"=&gt;"test"}}}}
    User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 113461968]]
    Student Load (0.2ms)  SELECT "students".* FROM "students" WHERE "students"."id" = 695735877 LIMIT 1
    Teacher Load (0.4ms)  SELECT "teachers".* FROM "teachers" WHERE "teachers"."id" = 657318460 LIMIT 1
     (0.1ms)  begin transaction
    Quiz Load (0.4ms)  SELECT "quizzes".* FROM "quizzes" WHERE "quizzes"."id" = 17663260 LIMIT 1
    CACHE (0.0ms)  SELECT "students".* FROM "students" WHERE "students"."id" = 695735877 LIMIT 1
    QuizResult Exists (0.1ms)  SELECT 1 FROM "quiz_results" WHERE ("quiz_results"."quiz_id" = 17663260 AND "quiz_results"."student_id" = 695735877) LIMIT 1
    CACHE (0.0ms)  SELECT "teachers".* FROM "teachers" WHERE "teachers"."id" = 657318460 LIMIT 1
    CACHE (0.0ms)  SELECT "teachers".* FROM "teachers" WHERE "teachers"."id" = 657318460 LIMIT 1
    Question Load (0.1ms)  SELECT "questions".* FROM "questions" WHERE "questions"."id" = 14376743 LIMIT 1
    SQL (0.3ms)  INSERT INTO "quiz_results" ("created_at", "message", "quiz_id", "student_id", "updated_at") VALUES (?, ?, ?, ?, ?)  [["created_at", Tue, 20 Mar 2012 10:20:24 UTC +00:00], ["message", nil], ["quiz_id", 17663260], ["student_id", 695735877], ["updated_at", Tue, 20 Mar 2012 10:20:24 UTC +00:00]]
     (0.1ms)  rollback transaction
    QuestionResponse Load (0.2ms)  SELECT "question_responses".* FROM "question_responses" WHERE "question_responses"."quiz_result_id" IS NULL
    Rendered quiz_results/_form.html.haml (5.0ms)
    Rendered quiz_results/new.html.haml within layouts/application (6.8ms)
    User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 113461968]]
    CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 113461968]]
    Student Load (0.1ms)  SELECT "students".* FROM "students" WHERE "students"."id" = 695735877 LIMIT 1
  Completed 200 OK in 37ms (Views: 13.4ms | ActiveRecord: 2.4ms)
  </code></pre>