Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate inner queries instead of join+distinct #605

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use primary_key method instead of hardcoded id
If the user changed it, then it wouldn't work
  • Loading branch information
fsateler committed Dec 9, 2019
commit cb2a0a982395c4d77d4325d5da2fbec3d47b88e1
2 changes: 1 addition & 1 deletion lib/cancan/model_adapters/active_record_5_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def build_relation(*where_conditions)
inner = @model_class.unscoped do
@model_class.left_joins(joins).where(*where_conditions)
end
@model_class.where(id: inner)
@model_class.where(@model_class.primary_key => inner)
else
@model_class.where(*where_conditions)
end
Expand Down