title: Rails cancan authorization based on association being denied
body: <p>I have the snippet below in my <code>ability.rb</code> file:</p>
  
  <pre><code>def initialize(user)
    if user.group === 1
      can :manage, Task do |task|
        task.user.id === user.id
      end
    end 
  end
  </code></pre>
  
  <p>The user <code>has_many</code> tasks and each task <code>belongs_to</code> a user.  The task record being requested (7) has a <code>user_id</code> of 4.  The user sending the request has a <code>user_id</code> of 4.</p>
  
  <p>In the tasks show method, I have this snippet to authorize and return the data:</p>
  
  <pre><code>def show
      @task = Task.find(params[:id])
  
      authorize! :read, @current_user
  
      render json: @task, root: "task"
  end
  </code></pre>
  
  <p>Why would it be denied?</p>