Forum: Ruby on Rails UltraSphinx help anyone?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
internetchris (Guest)
on 2009-04-22 19:25
(Received via mailing list)
Hey Everyone,

So I posted a thread last night with my problem, but since then I have
figured out the syntax a little better. I am trying to create indexes
on 2 separate models. I have an Account model that "has_many :names"

class Account < ActiveRecord::Base

has_many :names, :dependent => :destroy

is_indexed :fields => ['s_property_no'],
    :include => [{:association_name => "name", :field => 'name', :as
=> 'property_name'}]

 How do I setup the association between the account and name? When I
do rake ultrasphinx:configure, I get an error that says " You have a
nil object when you  didn't expect it! The error occured while
evaluation nil.constantize. For some reason it's not seeing my "name"

Here's the name model...

class Name < ActiveRecord::Base
  belongs_to :account

Any help is appreciated.


internetchris (Guest)
on 2009-04-22 20:12
(Received via mailing list)
Ha, I figured it out. I spent most of yesterday, and this morning on
this, and it was simple (usually is). I had my "is_indexed" defined in
the wrong model. It had to be defined in my name model rather than my
account model. It seems a little backwards in my head, but it works

On Apr 22, 9:24 am, internetchris <removed_email_address@domain.invalid>
internetchris (Guest)
on 2009-04-22 20:19
(Received via mailing list)
Ok, so I got it working. My is_indexed was defined in the wrong model.
Here's what I put in the "name" model rather than the "account" model.

 # Thinking Sphinx Search criteria
  is_indexed :fields => ['name','address','city','state','zip'],
    :include => [{:association_name => 'account', :field =>
's_property_no', :as => 's_property_no'},
                 {:association_name => 'account', :field =>
's_service_address', :as => 's_service_address'}

Does anyone know how I reference the 'name', 'address, etc from a view
within the account controller views? I can access the "s_property_no,
s_service_address" just fine. I'm not sure how I refer to the other
fields I am search on so I can display them in the search results.



On Apr 22, 9:24 am, internetchris <removed_email_address@domain.invalid>
internetchris (Guest)
on 2009-04-23 01:43
(Received via mailing list)
For my view code you can look here...

I would love advice from anyone, I am just taking stabs in the dark
right now.


On Apr 22, 10:19 am, internetchris <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.