Readme.md in simple_autocomplete-0.3.7 vs Readme.md in simple_autocomplete-0.3.8

- old
+ new

@@ -16,11 +16,11 @@ Examples ======== Controller ---------- -By default, `autocomplete_for` limits the results to 10 entries, +By default, `autocomplete_for` limits the results to 10 entries,<br/> and sorts by the autocomplete field. class UsersController < ApplicationController autocomplete_for :user, :name end @@ -34,10 +34,17 @@ # find and order with firstname/lastname # return full_name of records for auto-completion autocomplete_for :user, :full_name, :match => [:firstname, :lastname] +With :query and :mask option you can change the generated query + + # default: "LOWER(full_name) LIKE('%peter%')" + # now: "full_name LIKE('peter%') AND deleted_at IS NULL" + autocomplete_for :user, :full_name, :query => "%{field} LIKE(%{query}) AND deleted_at IS NULL", :mask => '%{value}%' + + With a block you can generate any output you need (ERB allowed): autocomplete_for :post, :title do |items| items.map{|item| "#{item.title} -- #{item.id} <%= Time.now %>"}.join("\n") end @@ -45,22 +52,22 @@ The items passed into the block is an ActiveRecord scope allowing further scopes to be chained: autocomplete_for :post, :title do |items| items.for_user(current_user).map(&:title).join("\n") end - + View ---- <%= f.text_field :auto_user_name, :class => 'autocomplete', 'data-autocomplete-url'=>autocomplete_for_user_name_users_path %> Routes ------ map.resources :users, :collection => { :autocomplete_for_user_name => :get} JS -- -use any library you like +use any library you like<br/> (includes examples for jquery jquery.js + jquery.autocomplete.js + jquery.autocomplete.css) jQuery(function($){//on document ready //autocomplete @@ -106,10 +113,10 @@ - [David Leal](http://github.com/david) - [mlessard](http://github.com/mlessard) - [Oliver Azevedo Barnes](http://github.com/oliverbarnes) - [Splendeo](http://www.splendeo.es) - [Franco Catena](https://github.com/francocatena) - -[Michael Grosser](http://grosser.it) -michael@grosser.it + +[Michael Grosser](http://grosser.it)<br/> +michael@grosser.it<br/> Hereby placed under public domain, do what you want, just do not hold me accountable...