Closed francescor closed 2 years ago
mmmh, then I probably ends up creating methods for Taggings that may mix up with the rest.
I ended up querying the db directly
def all_items_with_tags_for_model(my_class)
sql = "SELECT `taggings`.`taggable_id` FROM `taggings` WHERE `taggings`.`taggable_type` = '#{my_class}' AND `taggings`.`context` = 'tags'"
result = ActiveRecord::Base.connection.exec_query(sql).rows.flatten
end
any suggestion?
nope, at the end I end up with the same load.
well, I will keep using tag_counts.map(&:name)
While getting all tags for a Class, I've been using the following (which does not scale well):
What about creating
app/models/tagging.rb
withso to be able to access (read only) the table
taggings
directly? e.g.