implement synapse autocomplete controller function to make the results distinct. fixes #139

This commit is contained in:
Devin Howard 2013-03-16 13:30:54 -04:00
parent 6ed19db3ec
commit f714212423
2 changed files with 14 additions and 1 deletions

View file

@ -61,6 +61,9 @@ function nodeDoubleClickHandler(node, e) {
}//doubleClickNodeHandler
/*
* Returns a boolean saying if the node was double clicked in our understanding of the word
*/
function nodeWasDoubleClicked() {
//grab the timestamp of the click
var storedTime = MetamapsModel.lastNodeClick;

View file

@ -5,7 +5,17 @@ class SynapsesController < ApplicationController
respond_to :html, :js, :json
autocomplete :synapse, :desc, :full => true
def autocomplete_synapse_desc
term = params[:term]
if term && !term.empty?
items = Synapse.select('DISTINCT "desc"').
where('LOWER("desc") like ?', term.downcase + '%').
limit(10).order('"desc"')
else
items = {}
end
render :json => json_for_autocomplete(items, :desc)
end
# GET synapses
# or GET users/:user_id/synapses