# UltraSphinx help anyone?

**URL:** <https://www.ruby-forum.com/t/ultrasphinx-help-anyone/166188>\
**Category:** Rails\
**Created:** [April 22, 2009, 5:25pm UTC](https://www.ruby-forum.com/t/ultrasphinx-help-anyone/166188 "2009-04-22T17:25:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![internetchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c68b51/32.png) [@internetchris](https://www.ruby-forum.com/u/internetchris)\
**Post date:** [April 22, 2009, 5:25pm UTC](https://www.ruby-forum.com/t/ultrasphinx-help-anyone/166188/1 "2009-04-22T17:25:45Z")

</div>

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”  
model.

Here’s the name model…

class Name \< ActiveRecord::Base  
belongs\_to :account

Any help is appreciated.

Thanks!

Chris

---

<div class="post-metadata">

**Author:** ![internetchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c68b51/32.png) [@internetchris](https://www.ruby-forum.com/u/internetchris)\
**Post date:** [April 22, 2009, 6:12pm UTC](https://www.ruby-forum.com/t/ultrasphinx-help-anyone/166188/2 "2009-04-22T18:12:55Z")

</div>

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  
now.

On Apr 22, 9:24 am, internetchris [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![internetchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c68b51/32.png) [@internetchris](https://www.ruby-forum.com/u/internetchris)\
**Post date:** [April 22, 2009, 6:19pm UTC](https://www.ruby-forum.com/t/ultrasphinx-help-anyone/166188/3 "2009-04-22T18:19:57Z")

</div>

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.

Thanks!

Chris

On Apr 22, 9:24 am, internetchris [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![internetchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c68b51/32.png) [@internetchris](https://www.ruby-forum.com/u/internetchris)\
**Post date:** [April 22, 2009, 11:43pm UTC](https://www.ruby-forum.com/t/ultrasphinx-help-anyone/166188/4 "2009-04-22T23:43:27Z")

</div>

For my view code you can look here…

[http://railsforum.com/viewtopic.php?id=29736](http://railsforum.com/viewtopic.php?id=29736)

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

Chris

On Apr 22, 10:19 am, internetchris [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
