Forum: Ruby on Rails Simple auto-complete tutorial

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.
E9e97c333023338bcfc2789d48203ca8?d=identicon&s=25 David Dennis (mangala)
on 2009-03-18 23:09
I'm putting this here because it took too long to set up:

==============================

Things you'll need for auto_complete since everyone else was too lazy to
write down:

Example model is 'list'
Example field is 'name'

# Controller
auto_complete_for :list, :name
skip_before_filter :verify_authenticity_token, :only =>
[:auto_complete_for_list_name]

# view (edit.html.erb)
<%= javascript_include_tag :all, :cache => true %>
<% form_for(@list) do |f| %>
  <%= f.error_messages %>

  <p>
    New <%= f.label :name %>:&nbsp;<%= text_field_with_auto_complete
:list, :name %>
    <%= f.submit "Update" %>
<% end %>

# layout
<%= javascript_include_tag :defaults %>

# routes.rb
map.auto_complete ':controller/:action',
                  :requirements => { :action => /auto_complete_for_\S+/
},
                  :conditions => { :method => :get }
This topic is locked and can not be replied to.