Skip to content

Commit

Permalink
Merge pull request RolifyCommunity#206 from GoodGuide/master
Browse files Browse the repository at this point in the history
Add select(:id) to active record 'in' query to avoid MySQL errors in Rails 4.0.2
  • Loading branch information
EppO committed Jan 27, 2014
2 parents af8b36c + 7ccb3fc commit 0c01a28
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rolify/adapters/active_record/resource_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def resources_find(roles_table, relation, role_name)
end

def in(relation, user, role_names)
roles = user.roles.where(:name => role_names)
roles = user.roles.where(:name => role_names).select(:id)
relation.where("#{quote(role_class.table_name)}.#{role_class.primary_key} IN (?) AND ((resource_id = #{quote(relation.table_name)}.#{relation.primary_key}) OR (resource_id IS NULL))", roles)
end

Expand Down

0 comments on commit 0c01a28

Please sign in to comment.