Should [:city, {:franchise => :menus}] work in a normal Rails query?

-- 
Pat

On 27/03/2011, at 9:29 PM, ayoo wrote:

> Sorry I didn't realize I got a response.
> 
> Anyway, I'm using thinking_sphinx v2.0.0 on rails 3.  I just tried
> the :include => {:franchise => :menus} (without the array) and it now
> eagar loads the francise and the menus!  However there is still an
> issue.  In my app I am trying to eagar load another association as
> well.
> 
> When i try include => [:franchise, :city], it manages to eager load
> the 2 associations.  When i do :include => {:franchise => :menus}, it
> eagar loads the franchise and the menus.  Is there a way for me to
> eagar load all three associations?  I've tried include => [:city,
> {:franchise => :menus}], but it doesn't suppose this.
> 
> 
> 
> On Mar 23, 1:42 pm, Pat Allan <[email protected]> wrote:
>> Heya
>> 
>> Firstly - what version of Thinking Sphinx are you using? Also, what happens 
>> if you try :include => {:franchise => :menus} - removing the surrounding 
>> array?
>> 
>> --
>> Pat
>> 
>> On 23/03/2011, at 1:13 PM, ayoo wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Hi everybody and especially Pat.
>> 
>>> I have the following models:
>> 
>>> class Restaurant < ActiveRecord::Base
>>>  belongs_to :franchise
>>>  define_index...
>>> end
>>> class Franchise < ActiveRecord::Base
>>>  has_many :restaurants
>>>  has_many :menus
>>> end
>>> class Menu < ActiveRecord::Base
>>>  belongs_to :franchise
>>> end
>> 
>>> And i setup the sphinx index on my restaurant model.  When i search:
>>> Restaurant.search('food', :include => [:franchise])
>>> chains are eager loaded as expected.
>> 
>>> But is there a way to eager load menus as well?  I tried the normal
>>> rails convention of eager loading nested associations, but that didn't
>>> work
>>> Doesnt Work ## Restaurant.search('food', :include => [ { :franchise
>>> => :menus }])
>> 
>>> Can it be done and how? Thanks!
>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Thinking Sphinx" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to 
>>> [email protected].
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to