The tagged_with method paired with the on: parameter builds a query with a <= SQL operator rather than an explicit = operator. This causes models with multiple acts_as_taggable_on fields to return incorrect results.
For example,
Model.tagged_with('tagName', on: :taggable_field).count
SELECT COUNT(*) FROM "recipes" INNER JOIN "taggings" "model_taggings" ON "model_taggings"."taggable_id" = "models"."id" AND "model_taggings"."taggable_type" = 'Model' AND "model_taggings"."tag_id" IN (SELECT "tags"."id" FROM "tags" WHERE "tags"."name" ILIKE 'tagName') AND "model_taggings"."context" <= 'taggable_field'
The
tagged_with
method paired with theon:
parameter builds a query with a<=
SQL operator rather than an explicit=
operator. This causes models with multipleacts_as_taggable_on
fields to return incorrect results.For example,