Forum: Ruby on Rails searching using ajax

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.
sreekanth.G (Guest)
on 2008-12-08 11:37
(Received via mailing list)
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
Phlip (Guest)
on 2008-12-08 14:25
(Received via mailing list)
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 <a href='...'> tags, and they will hit a controller and
search...

--
   Phlip
sreekanth.G (Guest)
on 2008-12-08 15:08
(Received via mailing list)
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
This topic is locked and can not be replied to.