search autocomplete
This commit is contained in:
@@ -9,5 +9,20 @@ class ArtistController < ApplicationController
|
||||
end
|
||||
@artist = Artist.getByName(name)
|
||||
end
|
||||
|
||||
def autocomplete
|
||||
autocomplete = Artist.getLastFmAutocomplete(params[:query])
|
||||
return render :nothing => true if autocomplete.nil?
|
||||
suggestions = []
|
||||
pp autocomplete["response"]
|
||||
autocomplete["response"]["docs"].each do |doc|
|
||||
suggestions << doc["artist"] unless suggestions.include?(doc["artist"])
|
||||
end
|
||||
|
||||
render :json => {
|
||||
:query => params[:query],
|
||||
:suggestions => suggestions
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user