Forum: Ruby on Rails How to view resource with Ajax.autocompleter

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.
1df9fc8ddf084661265bbae74a8d0b43?d=identicon&s=25 jko170 (Guest)
on 2007-02-23 23:03
(Received via mailing list)
I have ajax.autocompleter working and I can get the string entered
into the field from the list. But how do I view that selected text
with the 'show' method? Here is my code:

-----  Controller --------
def autocomplete
    search = params[:user]
    @users = User.find(:all,
       :conditions => [ 'LOWER(first_name) LIKE ? OR LOWER(last_name)
       LIKE ?',
       "%#{search.downcase}%", "%#{search.downcase}%" ],
       :order => 'first_name, last_name DESC',
       :limit => 8) unless search.blank?
    render :partial => "search"
  end

------ autocompleter --------
<%= javascript_tag("new Ajax.Autocompleter('user',
                          'user_results',
                         '/autocomplete',
                        {indicator: 'spinner',
                         frequency: 0,
                         minChars: 1,
                        }
                        );") -%>

------- search partial ----------
<ul class="autocomplete_list">
<% for user in @users do -%>
  <li class="autocomplete_item">
    <div class="name"><%= link_to user.whole_name, user_path(user) %></
div>
  </li>
<% end -%>
</ul>

>From what I've read I think I need to use the updateAfterElement
option but I don't exactly know how. When the text is selected from
the list, I'd like it to invoke the 'show' medthod resulting in a url
like: http://domain.com/users/1

Thanks for any help!
1df9fc8ddf084661265bbae74a8d0b43?d=identicon&s=25 jko170 (Guest)
on 2007-02-23 23:11
(Received via mailing list)
Oh, and I also have
method: 'get'
added to the autocompleter
This topic is locked and can not be replied to.