Skip to content

Commit

Permalink
This avoids running a big SQL query which could potentially return a
Browse files Browse the repository at this point in the history
large number of rows. All we need to check for is existance of AT LEAST
one record. This can be done much faster with LIMIT 1.
  • Loading branch information
yankovski committed Jan 24, 2014
1 parent 45de8cf commit 73e1795
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 73e1795

Please sign in to comment.