From e1ac2605e33e7292aff507b3488e4f7d84727376 Mon Sep 17 00:00:00 2001 From: Gustavo Bazan Date: Thu, 10 Jan 2019 13:09:12 +0000 Subject: [PATCH] Optimize the roles_name memory allocation using pluck Avoid to instantiate models and just use the the returned values as they are --- lib/rolify/role.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rolify/role.rb b/lib/rolify/role.rb index 8e6f4367..34f6f13a 100644 --- a/lib/rolify/role.rb +++ b/lib/rolify/role.rb @@ -86,7 +86,7 @@ def remove_role(role_name, resource = nil) deprecate :has_no_role, :remove_role def roles_name - self.roles.select(:name).map { |r| r.name } + self.roles.pluck(:name) end def method_missing(method, *args, &block)