鉴于以下情况:
class Ns::Collection < ActiveRecord::Base
has_many :products, foreign_key: :ns_order_id , inverse_of: :collection
end
class NS::Product < ActiveRecord::Base
belongs_to :collection, foreign_key: :ns_order_id, inverse_of: :products
end
有人能解释为什么以下结果为真:
a = Ns::Collection.first
b = a.products[0]
a.code == b.collection.code
a.code = 'Something'
a.code == b.collection.code
但当我尝试预加载时,它返回false:
a = Ns::Collection.includes(:products).first
b = a.products[0]
a.code == b.collection.code
a.code = 'Something'
a.code == b.collection.code
暂无答案!
目前还没有任何答案,快来回答吧!