2

We're using cancan to authorize access to ~130 controllers, as things currently stand, this process takes ~100ms per authorization .. that is super slow (it literally takes around a second to just render the menu bar)

Is there techniques for breaking up cancan to simplify the work it needs to do per authorization, or in general speeding it up?

Does anyone have any cancan experiences to share?


Let me try to explain a bit better then .. We have cancan combined with a custom role system. Each role has a number of permissions, and based on if the user is allowed to do certain things, the cancan rules get dynamically built allowing it. In the end there is just one ability.rb file with a few hundred lines of rules which are dynamic based on the currently logged in user's role's permissions. (the roles are dynamic too).

The DB queries are already optimized, everything is eager loaded ahead of time and there is no wasteful queries done to fetch any of that stuff, but somewhere in there 100ms pass per check.

4

0 回答 0