You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.The text was updated successfully, but these errors were encountered: