Skip to content
New issue

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

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

Already on GitHub? # to your account

Auto eager loading broken for has_and_belongs_to_many associations that use the uniq option #16

Closed
jturkel opened this issue Sep 12, 2014 · 0 comments

Comments

@jturkel
Copy link
Member

jturkel commented Sep 12, 2014

Consider the following models:

class Post < ActiveRecord::Base
  has_and_belongs_to_many :authors, uniq: true
end

class Author < ActiveRecord::Base
  has_and_belongs_to_many :posts, uniq: true
end

The uniq option is ignored by Rails when eager loading Post#authors.

Note this is only a problem in Rails 3 since the uniq option was removed in Rails 4 (in favor of using a lambda to customize the association scope).

@jturkel jturkel changed the title Auto eager loading broken for associations that use the uniq option Auto eager loading broken for has_and_belongs_to_many associations that use the uniq option Sep 12, 2014
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant