Guest User

Untitled

a guest
Feb 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. def auto_complete_for_search_destination
  2. if params[:search][:destination].length > 2
  3. search = params[:search][:destination]
  4. conditions = ["city LIKE ? OR countries.country LIKE ?", "%" + search + "%", "%" + search + "%"]
  5. @destinations = City.find(
  6. :all,
  7. :conditions => conditions,
  8. :order => "SUBSTRING(cities.city,1,#{ search.length })=\"#{ sanitize_sql(search) }\" DESC, priority DESC"
  9. ) unless search.blank?
  10. else
  11. @destinations = Array.new
  12. end
  13. render :partial => "destinations"
  14. end
Add Comment
Please, Sign In to add comment