Rails 5: Jquery autocomplete
问题 I have implemented the jquery autocomplete within my rails app. And this is the setup: //= require jquery //= require rails-ujs //= require jquery-ui //= require bootstrap //= require_tree . items.js $(document).ready(function() { $("#search").autocomplete({ source: "/search_suggestions", autoFocus: true, select: function(event, ui) { $(event.target).val(ui.item.value); $('#search').closest("form").submit(); return false; } }); }); this is the search action inside the model items.rb def self