I am using acts_as_taggable_on in my current Rails project. On one overview page, I show an index of objects with tags associated with them. I am using the following code:
class Project < ActiveRecord::Base acts_as_taggable_on :categories end class ProjectsController < ApplicationController def index @projects = Project.all end end # in the view <% @projects.each do |p| %> <%= p.name %> <% p.category_list.each do |t| %> <%= t %> <% end %> <% end %>
Everything works as expected. However, if I show 20 projects, acts_as_taggable_on runs 20 requests to retrieve the associated tags.
How to enable tag loading in db source request?
Thank you for your time.
Erwinm
source share