It seems jbuilder make SQL query before render it jbuilder. Is not using ActiveRecord::Associations passed from controller correctly.
Example:
# Model
class Product
has_many :product_sides
has_many :product_side_images, through: :product_sides
end
# Controller
def index
@products = Product.includes(:product_side_images).references(:product_side_images)
end
Jbuilder make SQL query for getting each product_side and each product_side_images. (N*M + 1 query)
Calling Product.includes(:product_side_images).references(:product_side_images) and iterating from all it product_side_images from console for example it did just one SQL query.
It seems jbuilder make SQL query before render it jbuilder. Is not using ActiveRecord::Associations passed from controller correctly.
Example:
Jbuilder make SQL query for getting each product_side and each product_side_images. (N*M + 1 query)
Calling Product.includes(:product_side_images).references(:product_side_images) and iterating from all it product_side_images from console for example it did just one SQL query.