title: Rails Eager Loading CanCan Roles
body: <p>I am trying to speed up my app by eager loading some sql calls. I am using the CanCan gem to handle my admin authorization. I have a Roles table with three different roles and a many-to-many table roles_users. Each time a page loads with a CanCan ability set it does three separate sql queries. </p>
  
  <pre><code> Role Load (0.6ms)  SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles"."id"    
  = "roles_users"."role_id" WHERE "roles_users"."user_id" = 2 AND "roles"."name" = 'admin'  
    LIMIT 1
  Role Load (0.4ms)  SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles"."id" 
    = "roles_users"."role_id" WHERE "roles_users"."user_id" = 2 AND "roles"."name" =  
   'manager' LIMIT 1
   Role Load (0.3ms)  SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles"."id" 
    = "roles_users"."role_id" WHERE "roles_users"."user_id" = 2 AND "roles"."name" = 'user' 
    LIMIT 1 
  </code></pre>
  
  <p>I have tried putting a default_scope :include => :roles in the User class and also putting :includes in the has_and_belongs_to_many calls.</p>
  
  <p>Where can I eager load the Roles table to use only 1 SQL query?</p>