Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def auto_complete_for_search_destination
- if params[:search][:destination].length > 2
- search = params[:search][:destination]
- conditions = ["city LIKE ? OR countries.country LIKE ?", "%" + search + "%", "%" + search + "%"]
- @destinations = City.find(
- :all,
- :conditions => conditions,
- :order => "SUBSTRING(cities.city,1,#{ search.length })=\"#{ sanitize_sql(search) }\" DESC, priority DESC"
- ) unless search.blank?
- else
- @destinations = Array.new
- end
- render :partial => "destinations"
- end
Add Comment
Please, Sign In to add comment