Skip to content

Commit

Permalink
Merge pull request RolifyCommunity#216 from RallyPointNetworks/speedu…
Browse files Browse the repository at this point in the history
…p_roles_removal

Significant speed improvement when removing roles using limit(1)
  • Loading branch information
EppO committed Jan 27, 2014
2 parents 0c01a28 + 73e1795 commit 9cb745c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rolify/adapters/active_record/role_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def remove(relation, role_name, resource = nil)
if roles
relation.roles.delete(roles)
roles.each do |role|
role.destroy if role.send(ActiveSupport::Inflector.demodulize(user_class).tableize.to_sym).empty?
role.destroy if role.send(ActiveSupport::Inflector.demodulize(user_class).tableize.to_sym).limit(1).empty?
end
end
roles
Expand Down

0 comments on commit 9cb745c

Please sign in to comment.