You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is unexpected - can you run this with something that will show you location those queries are being generated from? Newer Rails should do it out of the box or something like https://github.com/brunofacca/active-record-query-trace will help
I've hit this as well. The location is as mentioned above, in the add method, the roles.includes call. It causes all roles to load, rather than having the DB do the work. It should be roles.exists instead.
We currently use Rolify in our application. Adding a role for a user was getting very slow and would break for most of our clients.
Doing some investigation I found the add method was doing this.
def add(relation, role) relation.roles << role unless relation.roles.include?(role) end
The includes seems to be loading ever record.
If someone could verify they are seeing the same thing I would really appreciate it. Currently using Rails 5.2.2
The text was updated successfully, but these errors were encountered: