Created
February 17, 2009 06:51
-
-
Save amerine/65612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#View | |
<label for="searchtext">Search for a specific fighter:</label> | |
<%= text_field_with_auto_complete :fighter, :contains, { :size => 15 }, :skip_style => true -%> | |
<p>Search Results:</p> | |
<div id="fighter_name_results"></div> | |
#Controller | |
def auto_complete_for_fighter_contains | |
fighter_query = params[:fighter][:contains] | |
@fighters = Fighter.find(:all, :conditions => ["first_name LIKE ? or last_name LIKE ? or ring_name LIKE ?",fighter_query,fighter_query,fighter_query]) unless fighter_query.blank? | |
render :partial => "_fighter_name_search_pane" | |
end | |
#Partial | |
<ul class="autocomplete_list"> | |
<% for fighter in @fighters %> | |
<li class="autocomplete_item"><%= link_to "#{fighter.first_name} #{fighter.last_name}", {:controller => :main, :action => :fighter, :id => fighter.id} %> | |
<% end %> | |
</ul> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment