سؤال

Using Globalize3 I am trying to load the following models including translations in a single query:

  • products (with product_translations)
  • properties (with property_translations)

When I try the query below it loads only the translations for product. Despite some tries, I have no idea how to load property_translations.

@products = Product.includes(:properties).with_translations

Edit (1)

My goal is to load the 2 models with translations with eager loading. Right now, It loads products, product_translations and properties in a single query but not property_translations

I have also tried:

Product.with_translations.all(:include => { :properties => :property_translations }

But the issue here is there is no property_translations model (table created with Globalize3)

Thanks for your thought!

هل كانت مفيدة؟

المحلول

I've got the answer from the following question: Rails 3 includes translations globalize3 activerecord which is:

@products = Product.includes([:translations, {:properties => :translations}])
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top