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

Fix adequate record modified relation warnings #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
2 changes: 2 additions & 0 deletions lib/protector/adapters/active_record/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def exec_queries_with_protector(*args)

# Preserve associations from internal loading. We are going to handle that
# ourselves respecting security scopes FTW!
relation = relation.clone
associations, relation.preload_values = relation.preload_values, []

@records = relation.send(:exec_queries).each { |record| record.restrict!(subject) }
Expand Down Expand Up @@ -179,6 +180,7 @@ def protector_substitute_includes(subject, relation)
end
end
else
relation = relation.clone
relation.preload_values += includes_values
relation.includes_values = []
end
Expand Down