cancan
cancan copied to clipboard
Only load necessary abilities?
I have an application with quite a few models and lots of "cans" and "cannots" associated with those models. The problem I'm running into is that running the initialize method on ability.rb makes quite a few database calls and the aggregate time to authorize a user per call into my API is quite long before I even execute code based on the authorization.
Is there a way to only run the ability definitions necessary for specific logic? Almost like lazy loading abilities? Am I missing something?