So,

That does index properly, but when I try to run facets, I get the
following error:

NoMethodError: undefined method 'doors'  for #<Array:0x271ad5c>
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/associations/association_proxy.rb:148:in `send'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/associations/association_proxy.rb:148:in `send'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet.rb:95:in `translate'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet.rb:94:in `each'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet.rb:94:in `translate'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet.rb:75:in `value'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet_search.rb:112:in
`add_from_results'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:183:in
`each_with_groupby_and_count'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/attribute_methods.rb:211:in `each_with_index'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:182:in `each'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:182:in
`each_with_index'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:182:in
`each_with_groupby_and_count'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet_search.rb:111:in
`add_from_results'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet_search.rb:47:in
`populate'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet_search.rb:45:in
`each'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet_search.rb:45:in
`populate'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/facet_search.rb:11:in
`initialize'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/search_methods.rb:404:in
`new'
        from /Users/manish/AcceleWeb/srcror/allvineyards.com/vendor/
plugins/thinking-sphinx/lib/thinking_sphinx/search_methods.rb:404:in
`facets'
        from (irb):4>>

Any idea?

Manish

On Sep 5, 4:36 pm, Pat Allan <[email protected]> wrote:
> If you want to index all the colours, then your example should  
> actually work (provided the association names are correct).
>
> If you want the number of doors for all bedrooms, then try the  
> following:
>    # to force the joins
>    has bedrooms.doors(:id), :as => :door_ids
>    # actual door count
>    has 'COUNT(doors.id)', :as => :door_count, :type => :integer
>
> --
> Pat
>
> On 05/09/2009, at 9:03 PM, mrmanishs wrote:
>
>
>
> > All,
>
> > How would I index attribute of a a one-to-many-to-many association?
>
> > Example:
>
> > House ==> has many bedrooms
> > each bedroom has many doors, of a certain color. I don't have
> > a :through relationship because it's one to many, so house_id is
> > stored on the bedroom table.
>
> > How would I tell it to index it so that House knows how many colored
> > doors it has for its bedrooms? I'd like to do something like this
> > (obviously it doesn't work):
>
> > class House << ActiveRecord::Base
> >   has_many :bedrooms
>
> >  define_index do
> >    indexes bedrooms.doors.color, :as => :bedroom_door_color, :facet
> > => true
> >  end
>
> > end
>
> > Thanks.
>
> > Manish
>
>
--~--~---------~--~----~------------~-------~--~----~
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