Resources

Summary

# Gemfile
gem 'goldiloader'

# index.html.erb
      <% blog.tags.to_a.map(&:name).each do |tag| %>
      <%# blog.tag_list.each do |tag| %>
        <div class='badge'>
          <%= tag %>
        </div>
      <% end %>

# config/initializers/goldiloader.rb
ActiveRecord::Associations::Association.default_auto_include = false
# ActiveRecord::Associations::HasManyThroughAssociation.default_auto_include = false

# blog.rb
class Blog < ActiveRecord::Base
  acts_as_taggable
  # If you set the initializer file to not auto_include, 
  # you can manually force an auto include
  # has_many :posts, auto_include: true
  
  # Since goldiloader is set to auto_include be default,
  # this behavior can be overridden.
  # has_many :posts, auto_include: false
end