title: Passing value from view to helper
body: <p>I have the following tables:</p>
  
  <pre><code>projects
  users
  projects_users &lt;- relational table
  </code></pre>
  
  <p>In the view I'm looping through all the projects and render them out one and one with different classes (as well as linked or not linked)depending the relation a user has to it (owner, member, not a member).</p>
  
  <p>This works well except for the if statement on line 3, where I check whether or not the user is a member. 'check_if_member' is to be found in the projects helper (see below). What happens is that I get the following error message:</p>
  
  <pre><code>Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
  </code></pre>
  
  <p>...which (if I got it right) means that either '@project.id' or 'current_user.id' is nil. In this case I'm pretty sure it's @project.id that's nil, and that it's actually not passed to the helper.</p>
  
  <p>If I'm right, how do I pass it to the helper?
  If I'm not right, what is the problem?</p>
  
  <p><strong>the view:</strong></p>
  
  <pre><code>1.  &lt;% @projects.each do |project| %&gt;
  2.      &lt;div class="project_container"&gt;
  3.          &lt;% if check_if_member %&gt;
  4.              &lt;% if project.user_id == current_user.id %&gt;
  5.                  &lt;div class="users_project label label-success"&gt;
  6.                      Owner
  7.                  &lt;/div&gt;
  8.              &lt;% else %&gt;
  9.                  &lt;div class="not_users_project label label-info"&gt;
  10.                     Member
  11.                 &lt;/div&gt;
  12.             &lt;% end %&gt;
  13.             &lt;div class="project_name_div"&gt;
  14.                 &lt;%= link_to (project.title), project_path(project) %&gt;&lt;br /&gt;
  15.             &lt;/div&gt;
  16.         &lt;% else %&gt;
  17.             &lt;div class="project_name_div"&gt;
  18.                 project.title &lt;br /&gt;
  19.             &lt;/div&gt;
  20.         &lt;% end %&gt;
  21.     &lt;/div&gt;
  22. &lt;% end %&gt;
  </code></pre>
  
  <p><strong>the helper:</strong></p>
  
  <pre><code>module ProjectsHelper
      def check_if_member
          if ProjectsUser.where("project_id = ? AND user_id = ?", @project.id, current_user.id)
              return true
          else
              return false
          end
      end
  end
  </code></pre>