title: Rails: Reference to new Model throwing error
body: <p>I have a working users table.
  I have generated a new table using:  </p>
  
  <pre><code>rails generate model quiz_answers
  </code></pre>
  
  <p>..and run rake db:migrate</p>
  
  <p>My CreateQuizAnswers migration file looks like this:  </p>
  
  <pre><code>class CreateQuizAnswers &lt; ActiveRecord::Migration
    def change
      create_table :quiz_answers do |t|
        t.references :user, index: true
        t.string :answer1
        t.string :answer2
        t.string :answer3
        t.string :answer4
        t.string :answer5
        t.string :answer6
        t.string :answer7
        t.string :answer8
  
        t.timestamps
      end
    end
  end
  </code></pre>
  
  <p>I have a quiz_answer model:  </p>
  
  <pre><code>class QuizAnswer &lt; ActiveRecord::Base
      belongs_to :user
  end
  </code></pre>
  
  <p>and a QuizAnswersController:  </p>
  
  <pre><code>class QuizAnswersController &lt; ApplicationController
      def new
          @user = current_user
          @quiz_answer = current_user.quiz_answer.build
      end
  
      private 
  
      def post_params
          params.require(:quiz_answer).permit(:body, :user_id)
      end
  end
  </code></pre>
  
  <p>I have added :quiz_answers as a resource in routes.rb  </p>
  
  <p><strong>Edited question:</strong>   </p>
  
  <p><strong>WHY, then, when I try to build a form (using Devise) do I get the error "undefined method `body' for...(with a reference to QuizAnswer here)"? I have another model 'Post' which does not generate this error and does not have a 'body' attribute.</strong></p>
  
  <p>The page where I'm trying to build the form is home/whattypeofleader.html.erb and, in routes.rb I have:  </p>
  
  <pre><code>get "whattypeofleader" =&gt; "home#whattypeofleader"
  </code></pre>
  
  <p>And in my HomeController I have:</p>
  
  <pre><code>class HomeController &lt; ApplicationController
      def index
      end
  
      def whattypeofleader
          @user = current_user
          @quiz_answer = current_user.quiz_answer.build
      end
  end
  </code></pre>
  
  <p>What the HELL am I doing wrong? Any help desperately appreciated, thanks.</p>
  
  <p>Oh, and in case you need it, here's the form code, a partial that gets 'rendered' in whattypeofleader:  </p>
  
  <pre><code>&lt;%= form_for([current_user, @quiz_answer]) do |f| %&gt;
    &lt;p&gt;
      &lt;%= f.text_area :body, :autofocus =&gt; true , :class =&gt; "elearning-input"%&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &lt;%= f.submit("Save entry") %&gt;
    &lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>