I am bit confused with these issue
Here is the Item model
class Item < ActiveRecord::Base
has_many :true_items, :foreign_key => "parent_id", dependent: :destroy
end
Here is the TrueItem model
class TrueItem < ActiveRecord::Base
attr_accessible :item_id, :parent_id
belongs_to :parent, :class_name => "Item"
belongs_to :item
end
Here am taking all the items includes true_items
items = Item.includes(:true_items)
items.each do |item|
item.true_items.each do | true_item |
true_items = "#{true_item.item.name}"
end
end
Here the problem is, when i am taking the item.name like "#{true_item.item.name}" in the loop, duplicate query happening, that means again calling that item get the name. is there any issue with that association?