Feature/sql permission checks

Reimplements permission checks in Arel/SQL which in turn improves extensibility and performance. Adds various performance improvements on other layers.
Line is too long. [103/99]<br>Prefer single-quoted strings when you don't need string interpolation or special symbols.