Having trouble with CanCan

So I got CanCan and Devise working well. I have two types of users: Admins and Nonadmins. Admins can edit all of Nonadmins profiles.

The problem is, every user (either Admin or Nonadmin) belongs to an Account or Organization. Admins should only be able to edit users from their own Account or Organization. I was able to do that too.

The problem is, I can't display the links to the edit buttons. Everything seems fine, I don't see any errors.

Here is what I have in ABILITY.RB

Nevermind, I found the problem. I was supposed to remove the @ because it's iterating from a loop:

<% @users.each do |user| %>

<%     if user.first_name.nil? or user.last_name.nil?       user_link = link_to 'User Details', user, :class=>'first_and_last_name'     else       user_link = link_to user.first_name + ' ' + user.last_name, user, :class=>'first_and_last_name'     end %>

  <% user_name = user.first_name.to_s + ' ' + user.last_name.to_s %>

  <div class="div_user">     <span class="span_name"><%= link_to user_name, edit_user_path(user) %></span>     <span class="span_title"><%= user.title %></span>     <span class="span_email"><%= user.email %></span>

    <% if user.role == 'admin' %>       <span class="span_role"><%= user.role %></span>     <% end %>

    <% if can? :update, user %>     <span class="span_user_controls">       <%= link_to 'Edit', edit_user_path(user) %>       <%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %>     </span>     <% end %>   </div> <% end %> </div>