# UltraSphinx Concatenate Syntax?

**URL:** <https://www.ruby-forum.com/t/ultrasphinx-concatenate-syntax/166133>\
**Category:** Rails\
**Created:** [April 22, 2009, 5:58am UTC](https://www.ruby-forum.com/t/ultrasphinx-concatenate-syntax/166133 "2009-04-22T05:58:18Z")\
**Posts on this page:** 1\
**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:58am UTC](https://www.ruby-forum.com/t/ultrasphinx-concatenate-syntax/166133/1 "2009-04-22T05:58:18Z")

</div>

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
