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

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

Comments

Projects
None yet
2 participants

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.

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