Skip to content

Commit

Permalink
Fixed distinct bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeyers22 committed May 1, 2017
1 parent 947ab6c commit b1495cc
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 @@ -21,7 +21,7 @@ def resources_find(roles_table, relation, role_name)
resources = relation.joins("INNER JOIN #{quote_table(roles_table)} ON #{quote_table(roles_table)}.resource_type IN (#{relations}) AND
(#{quote_table(roles_table)}.resource_id IS NULL OR #{quote_table(roles_table)}.resource_id = #{quote_table(relation.table_name)}.#{quote_column(relation.primary_key)})")
resources = resources.where("#{quote_table(roles_table)}.name IN (?) AND #{quote_table(roles_table)}.resource_type IN (?)", Array(role_name), klasses)
resources = resources.select("#{quote_table(relation.table_name)}.*").distinct
resources = resources.select("DISTINCT ON (id) #{quote_table(relation.table_name)}.*")
resources
end

Expand Down

0 comments on commit b1495cc

Please sign in to comment.