title: unable to set if else conditions with has-many through association in rails 4 view
body: <p>I am working on an application with has_many through association.
  in <code>employee.rb</code></p>
  
  <pre><code>class Employee &lt; ActiveRecord::Base
   has_many :inventories, through: :employee_inventories
  end
  </code></pre>
  
  <p>in <code>inventory.rb</code></p>
  
  <pre><code>class Inventory &lt; ActiveRecord::Base
    has_many :employees, through: :employee_inventories
  end
  </code></pre>
  
  <p>in <code>employee_inventories.rb</code></p>
  
  <pre><code>class EmployeeInventory &lt; ActiveRecord::Base
    belongs_to :employee
    belongs_to :inventory
  end
  </code></pre>
  
  <p>Everything is fine with this association. But when I implement if-elsif condition with accessing status column from employee_inventory. Like that</p>
  
  <pre><code>&lt;% if (inventory.is_available == false &amp;&amp; current_employee[:role] == 'INVENTORY') %&gt;
       &lt;% if(inventory.employee_inventories.collect{|e| e.status == 'REQUESTED'}) %&gt;
             &lt;%= link_to 'Allot', inventory_available_status_inventory_path(inventory,   :employee_inventory =&gt; { :status =&gt; 'ALLOTTED' }) %&gt;
              &lt;%= link_to 'Cancel', inventory_available_status_inventory_path(inventory, :employee_inventory =&gt; { :status =&gt; 'CANCELLED' } ) %&gt;
       &lt;% elsif (inventory.employee_inventories.collect{|e| e.status == 'ALLOTTED'}) %&gt; 
              &lt;%= link_to 'return'%&gt;
        &lt;% end %&gt;
  &lt;% elsif inventory.is_available == true %&gt;
       &lt;%= link_to 'Request for inventory',request_inventories_inventory_path(inventory, :employee_inventory =&gt; { :employee_id =&gt; current_employee, :status =&gt; 'REQUESTED', :inventory_id =&gt; inventory}) %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>In code when update status of employee_inventory to REQUESTED. Everything goes fine but after when I update status to ALLOTTED then second elsif condition is unable to execute.</p>
  
  <p>from <code>inventory.employee_inventories.collect{|e| e.status == 'ALLOTTED'}</code> 
  Output:- </p>
  
  <blockquote>
    <p>[true]</p>
  </blockquote>
  
  <p>I am confused why is it not executing in second time. Please guide me. Thank in advance.</p>