Skip to content

Instantly share code, notes, and snippets.

@abelorian
Created January 10, 2017 03:19
Show Gist options
  • Save abelorian/cdbf421f0e3a7787bbdacb2f8b353332 to your computer and use it in GitHub Desktop.
Save abelorian/cdbf421f0e3a7787bbdacb2f8b353332 to your computer and use it in GitHub Desktop.
Rails js render
def autocomplete
query = params[:q]
@data = SearchService.autocomplete(query)
render text: render_to_string(:action => "partials/_autocomplete.html.erb", :layout => false, data: @data)
end
# $.get( search_autocomplete_url, {q: query}, function(res) {
# $("#search-container").html(res);
# })
# .fail(function() {
# console.log( "error" );
# });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment