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

.page() introduces duplicates in HABTM :uniq relationship #255

Open
johngtimms opened this issue Jul 30, 2012 · 1 comment
Open

.page() introduces duplicates in HABTM :uniq relationship #255

johngtimms opened this issue Jul 30, 2012 · 1 comment

Comments

@johngtimms
Copy link

blog_posts.rb
has_and_belongs_to_many :tags, :uniq => true

tag.rb
has_and_belongs_to_many :blog_posts, :uniq => true

Per the documentation for ActiveRecord, :uniq does not prevent duplicate relationships being stored, it just ignores them when building the query.

Here is the issue:
tag = Tag.find(1)
tag.blog_posts.count equals 1, but:
tag.blog_posts.page(nil).count equals 3, and all 3 are duplicates of the same post. The correct behavior should be to show only 1, not duplicated.

@anthonyalberto
Copy link

See #251

It's a problem with Rails

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

No branches or pull requests

2 participants