# Searching using ajax

**URL:** <https://www.ruby-forum.com/t/searching-using-ajax/155118>\
**Category:** Rails\
**Created:** [December 8, 2008, 10:37am UTC](https://www.ruby-forum.com/t/searching-using-ajax/155118 "2008-12-08T10:37:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreekanth.G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@sreekanth.G](https://www.ruby-forum.com/u/sreekanth.G)\
**Post date:** [December 8, 2008, 10:37am UTC](https://www.ruby-forum.com/t/searching-using-ajax/155118/1 "2008-12-08T10:37:33Z")

</div>

hi,

i have implimented one application with search facility.  
Now i want u se the ajax application for searching using the tags  
created?  
how can we do that?

if some one worked on this help me.

thanks  
srikanth

---

<div class="post-metadata">

**Author:** ![sreekanth.G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@sreekanth.G](https://www.ruby-forum.com/u/sreekanth.G)\
**Post date:** [December 8, 2008, 1:25pm UTC](https://www.ruby-forum.com/t/searching-using-ajax/155118/2 "2008-12-08T13:25:54Z")

</div>

sreekanth.G wrote:

> i have implimented one application with search facility.  
> Now i want u se the ajax application for searching using the tags created?  
> how can we do that?

Saying you want to use Ajax there is “solution probleming” - the  
opposite of  
“problem solving”. You have thought of a solution, and want it to match  
the problem!

What user experience do you expect? If you have a tag cloud, users can  
click on  
it with lowly tags, and they will hit a controller and  
search…

–  
Phlip

---

<div class="post-metadata">

**Author:** ![sreekanth.G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@sreekanth.G](https://www.ruby-forum.com/u/sreekanth.G)\
**Post date:** [December 8, 2008, 2:08pm UTC](https://www.ruby-forum.com/t/searching-using-ajax/155118/3 "2008-12-08T14:08:14Z")

</div>

hi pilip,

simple search with ajax is working fine for me.  
Problem is if i give some tagname using acts\_as\_taggable\_on\_steroids  
to the table entries im getting error like no record found:

example:  
strams table contents and corresponding tags showned below:

id name resolution framerate location bitrate tagname  
1 ac.264 720x480 30fps c:/data 4mbps 264

from the above if i enter a name of table entry like :  
ac.264 in the search box its giving corresponding names having the  
table with that name i.e ab.264

corresponding method defined in controller is:

def get\_results  
if request.xhr?  
if params[‘search\_text’].strip.length \> 0  
terms = params[‘search\_text’].split.collect do |word|  
“%#{word.downcase}%”  
end  
@streams= Stream.find(  
:all,  
:conditions =\> [  
( ["(LOWER(title) LIKE ?)"] \* terms.size ).join(" AND "),  
\* terms.flatten  
]  
)  
end  
render :partial =\> “search”  
else  
redirect\_to :action =\> “index”  
end  
end  
end

im the same way i tried to search using tag name like;  
if i enter 264 as tag name in search box what i am expecting is the  
corresponding table entries like  
ac.264 720x480 30fps c:/data 4mbps

to achieve this i modified the method in controller like:

def get\_results  
if request.xhr?  
if params[‘search\_text’].strip.length \> 0  
terms = params[‘search\_text’].split.collect do |word|  
“%#{word.downcase}%”  
end  
@streams= Stream.find\_taggable\_with(params[:terms])  
end  
render :partial =\> “search”  
else  
redirect\_to :action =\> “index”  
end  
end  
end

here if i enter the tag name its giving the result as :  
no record found from get\_results

can you tell me where exactly i am doing mistake and need to do  
modifications.

thanks alot  
srikanth
