Skip to content

Instantly share code, notes, and snippets.

@marzdgzmn
Created June 23, 2019 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marzdgzmn/149dfcdee71c0fc694159579963bfef3 to your computer and use it in GitHub Desktop.
Save marzdgzmn/149dfcdee71c0fc694159579963bfef3 to your computer and use it in GitHub Desktop.
//= require jquery
//= require jquery-ui
//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require_tree .
<%= form_with url: admin_studies_edit_path, method: :get, local: true do |f| %>
<%= f.text_field :study_title, data: { autocomplete_source: admin_studies_path} %>
<%= f.submit 'Search', class: 'button-special' %>
<% end %>
(function($) {
return $('#study_title').autocomplete({
source: $('#study_title').data('autocomplete-source')
});
}(jQuery);
def index
@studies = Study.search(params[:term])
respond_to do |format|
format.html
format.json { render json: @studies.map(&:title) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment