title: undefined method `each' for nil:NilClass?
body: <p>I want to dynamically create checkboxes with the users in the database, which shall be possible to choose (one or many). However, I am apparently doing something wrong because the code below gives me the following error:</p>
  
  <pre><code>undefined method `each' for nil:NilClass
  ...
  &lt;% @users.each do |user| %&gt; &lt;--- the line with the error
  </code></pre>
  
  <p><strong>the controller:</strong></p>
  
  <pre><code>class ProjectsController &lt; ApplicationController
      ...
  
      def new
        @project = Project.new
        @users = (current_user.blank? ? User.all : User.find(:all, :conditions =&gt; ["id != ?", current_user.id]))
      end
  
      ...
  end
  </code></pre>
  
  <p><strong>the view (new.html.erb):</strong></p>
  
  <pre><code>&lt;%= form_for @project do |f| %&gt;
      &lt;div class="alert alert-block"&gt;  
          &lt;%= f.error_messages %&gt;
      &lt;/div&gt;
      &lt;div class="text_field"&gt;
          &lt;%= f.label :title%&gt;
          &lt;%= f.text_field :title%&gt;
      &lt;/div&gt;
      &lt;div class="text_field"&gt;
          &lt;%= f.label :description%&gt;
          &lt;%= f.text_field :description%&gt;
      &lt;/div&gt;
      &lt;div class="dropdown"&gt;
          &lt;%= f.label :start_date%&gt;
          &lt;%= f.date_select :start_date %&gt;
      &lt;/div&gt;
      &lt;div class="dropdown"&gt;
          &lt;%= f.label :end_date%&gt;
          &lt;%= f.date_select :end_date %&gt;
      &lt;/div&gt;
      &lt;% @users.each do |user| %&gt;
          &lt;%= check_box_tag "project[member_ids][]", user.id, @project.member_ids.include?(user.id), :id =&gt; "user_#{user.id}" %&gt; 
          &lt;%= label_tag "user_#{user.id}", user.first_name %&gt;
      &lt;% end %&gt;
      &lt;div class="checkbox"&gt;
  &lt;/div&gt;
      &lt;div class="submit"&gt;
          &lt;%= f.submit "Spara" %&gt;
      &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>the model:</strong></p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
    has_and_belongs_to_many :users
    belongs_to :user
    has_many :tickets, :dependent =&gt; :destroy
  
    ... validations ...
  
    attr_accessible :user_id, :title, :description, :start_date, :end_date
  end
  </code></pre>
  
  <p>I have five users in my database, so the table isn't empty or anything. What am I doing wrong here?</p>