title: .collect method get an error undefined method `collect' for nil:NilClass
body: <p>I'm trying to have a drop down list but when i try it it give me </p>
  
  <p>undefined method `collect' for nil:NilClass</p>
  
  <p>the controller:</p>
  
  <pre><code>def existing
  
                  @courses = Course.all
  
      end
      def duplicate
          course = Course.find_by_id(permitd_up[:id])
          new_course = course.dup
          if new_course.save
              redirect_to :action =&gt; 'show'
          else
              redirect_to :back
          end
      end
  </code></pre>
  
  <p>the view:</p>
  
  <pre><code>&lt;h3&gt;Choose a Course&lt;/h3&gt;
      &lt;%= form_for :course , url: {:action =&gt; "duplicate" , method: "post"} do |f|%&gt;
          &lt;%= f.select :id , @courses.collect{|c| [c.id , c.name]} %&gt;
      &lt;br&gt;&lt;br&gt;
      &lt;%= f.submit%&gt;
  
      &lt;%end%&gt;
  </code></pre>