1

so I"m new to rails and web development and I've trawled through loads of forums and documents trying to understand how to achieve this (there's so many different options!) but after hours and hours I honestly can't figure it out so I'm just gonna ask here and hope someone helps me out!

I have this search form

<%= form_tag({controller: "ansible_jobs", action: 'find'}, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Human run", autocomplete: 'off'%>
<%= submit_tag "Search", :name => nil %>

This is my find method

def find
@ansible_job = AnsibleJob.search(params[:search])
if !@ansible_job.empty?
  job = @ansible_job.first
  redirect_to( {:controller => "ansible_jobs", :action => "show", :run_id => job.run_id}, {:method => :get})
end
end

This is my search method

def self.search(query)
    where('human_run_id LIKE ?', "%#{query}%")
  end

And basically I want to implement autocompletion in my search field that queries my database using Ajax for the existing human_run_id in my database.

Help would be greatly appreciated as I currently don't even know where to begin.

Pronitron
  • 177
  • 8