title: Ruby on Rails - undefined method `map' for nil:NilClass
body: <p>I have spent the past few hours trying to figure out what I am doing wrong, but I cannot come to a solution.  Simply put, I am trying to populate a select box with data from a table called 'semesters'.  (I've seen tons of questions regarding this on SO, but I cannot get them to work with my app).</p>
  
  <p>Here's what I have:</p>
  
  <h1>Courses Controller</h1>
  
  <pre><code>class CoursesController &lt; ApplicationController
    def create
     @semesters = Semester.all()
     @course = Course.new(params[:course])
      # Save the object
      if @course.save
        flash[:notice] = "Course created."
        redirect_to(:action =&gt; 'list')
      else
        # If save fails, redisplay the form so user can fix problems
        render('new')
      end
    end
  end
  </code></pre>
  
  <h1>View</h1>
  
  <pre><code>#views/courses/new.html.erb
  &lt;%= form_for(:course, :url =&gt; {:action =&gt; 'create'}) do |f| %&gt;
     &lt;%= f.select(:semester, @semesters.map { |s| [ s.name, s.id ] }) %&gt;
     &lt;%= submit_tag("Create Course") %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I was hoping it would output:</p>
  
  <pre><code>  &lt;select&gt;
      &lt;option id="1"&gt;Spring 2013&lt;/option&gt;
      &lt;option id="2"&gt;Fall 2013&lt;/option&gt;
    &lt;/select&gt;
  </code></pre>
  
  <p>But instead, I am getting the error:</p>
  
  <pre><code> views/courses/new.html.erb where line #32 raised:
  
        undefined method `map' for nil:NilClass
  </code></pre>
  
  <p>Line #32 corresponds to my form helper select.</p>
  
  <p>Any help on this would be great!</p>