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

Add query_constraints qualifier to the association matcher. #1592

Closed
matsales28 opened this issue Dec 19, 2023 · 0 comments · Fixed by #1604
Closed

Add query_constraints qualifier to the association matcher. #1592

matsales28 opened this issue Dec 19, 2023 · 0 comments · Fixed by #1604

Comments

@matsales28
Copy link
Member

Rails 7.1 introduced the query_constraints qualifier that can be passed to the association definition.

For example:

class Author < ApplicationRecord
  self.primary_key = [:first_name, :last_name]
  has_many :books, query_constraints: [:first_name, :last_name]
end

class Book < ApplicationRecord
  belongs_to :author, query_constraints: [:author_first_name, :author_last_name]
end

The idea here is to add the query_constraints qualifier to our association matchers.

https://edgeguides.rubyonrails.org/active_record_composite_primary_keys.html#associations-between-models-with-composite-primary-keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant