acts-as-taggable-on
acts-as-taggable-on copied to clipboard
.tagged_with([], any:true) always selects all fields, v.6.0.0
Hi all,
the query below selects only ids as expected and can be used later e.g. in where statement:
Person.tagged_with(['tag1', 'tag2']).select(:id)
but the next query selects all fields, ignoring select(:id):
Person.tagged_with(['tag1', 'tag2'], any: true).select(:id)
I found the following code in any_tags_query.rb:
def build
taggable_model.select(all_fields)
.where(model_has_at_least_one_tag)
.order(Arel.sql(order_conditions))
.readonly(false)
end
Can the select(all_fileds) statement be removed?
Meanwhile, the workaround I've found is to unscope select fromtagged_with first and then select necessary fields:
Person.tagged_with(['tag1', 'tag2']).unscope(:select).select(:id)
Same issue here, thanks for your workaround!