Forum: Ruby on Rails UltraSphinx help anyone?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D0b55f385fc038fc7fc588a9c59c3618?d=identicon&s=25 internetchris (Guest)
on 2009-04-22 17: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"
model.


Here's the name model...

class Name < ActiveRecord::Base
  belongs_to :account


Any help is appreciated.

Thanks!

Chris
D0b55f385fc038fc7fc588a9c59c3618?d=identicon&s=25 internetchris (Guest)
on 2009-04-22 18: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
now.



On Apr 22, 9:24 am, internetchris <ch...@silhouettesolutions.net>
D0b55f385fc038fc7fc588a9c59c3618?d=identicon&s=25 internetchris (Guest)
on 2009-04-22 18: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.

Thanks!

Chris


On Apr 22, 9:24 am, internetchris <ch...@silhouettesolutions.net>
D0b55f385fc038fc7fc588a9c59c3618?d=identicon&s=25 internetchris (Guest)
on 2009-04-22 23:43
(Received via mailing list)
For my view code you can look here...

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 <ch...@silhouettesolutions.net>
This topic is locked and can not be replied to.