title: Cancan user permission?
body: <p>I am using cancan for permissions and I would like it so users cannot see other users when visiting their profile/users page. User should only be able to see themselves. </p>
  
  <p>In my ability.rb file I have</p>
  
  <pre><code>class Ability
  include CanCan::Ability
  
  def initialize(user)
     user ||= User.new # guest user (not logged in)
  
     if user.role? :admin
       can :manage, :all
     elsif user.role? :rookie 
       can [:update, :destroy], [Album, Photo, User]
       can :read, :all
     end
  
    can :manage, Album, :profile =&gt; { :user_id =&gt; user.id }
    can :manage, Photo, :profile =&gt; { :user_id =&gt; user.id }
    can :manage, Video, :profile =&gt; { :user_id =&gt; user.id }
    can :manage, Comment, :blog =&gt; { :profile =&gt; { :user_id =&gt; user.id } }
    can :manage, User, :id =&gt; user.id
   end
  end
  </code></pre>
  
  <p>In my users_controller I have</p>
  
  <pre><code>class UsersController &lt; ApplicationController
  before_filter :authenticate_user!
  load_and_authorize_resource 
  
   def index
     @user = current_user
   end
  
   def show
    @user = User.find(params[:id])
   end
  end
  </code></pre>
  
  <p>The above usually works but since user is the primary model I am not sure how I can resolve this. Rails gives me the error</p>
  
  <pre><code>undefined method `user_id'
  </code></pre>