Hey everyone,
I hope someone on this group can help me with an UltraSphinx question.
I am using rails 2.3.2 and I am trying to figure out how
to search my "has_many" model. Here''s the example..
I can search my "Account" model just fine. My Account model
"has_many :names"
I would like to search my Account model, and my Name model at the
same
time. I have seen a few examples, but I can''t seem to get it to
work.
I am pretty familiar with SQL, but I haven''t done a JOIN in a while,
and I usually get them backwards if I don''t have an example to
follow.
Quick run down...
account.rb
------------------------------------------------------------
has_many :names, :dependent => :destroy
is_indexed :fields => [''s_property_no'',
''s_service_address''],
:concatenate => [{ :class_name => ''Name'', :field
=>
''name'', :association_sql => "LEFT JOIN accounts ON
(accounts.id = name.account_id)", :as => ''accounts'' }]
end
name.rb
-----------------------------------------------------------
belongs_to :account
I am sure I have the "is_indexed" statement messed up. This is where
I
need the help. My "search" function is defined in the "accounts
controller". The only other question I have is what do I put in my
view so the name can be displayed in addition to the account
information? I know how to display the account info, just not the
name
info.
Thanks!
Chris