acts_as_taggable_on: how to optimize the query?

前端 未结 3 893
攒了一身酷
攒了一身酷 2021-02-08 19:14

I use acts_as_taggable_on in my current Rails project. On one overview page i am displaying an index of objects with their associated tags. I use the following code

3条回答
  •  我寻月下人不归
    2021-02-08 19:41

    I agree with Jan Drewniak, huge performance boosted with

    Download.includes(:tags).all
    

    and in views:

    download.tags.map {|t| link_to t, t.name}.join(', ')
    

    But still too slow.

    Any other idea?

提交回复
热议问题