I am new to ruby and am having trouble implementing the view for search in haml syntax.
Here is my controller code for search which works fine
app/controllers/search
def search(text)
@patients = @client.submit_search({ query: text, page: 1, page_size: 30 })
end
This is my route in /config
match 'patients/index' => 'search/patients#index', via: :get
This is my views where in contains the form:
//Search Form
%h2 Patient Search
.search-form-elements
%form{ :action => "", :method => "get"}
%label{:for => "name"} First Name:
%input{:type => "text", :name =>"first_name"}
%label{:for => "name"} Last Name:
%input{:type => "text", :name =>"last_name"}
%label{:for => "name"}
%input{:type => "submit", :value => "Search", :class => "button"}
%table.table.table-bordered.table-condensed
%tr
%th
Patient Name
%th
Id#
%th
Age
%th
Gender
Basically when I type some text and hit submit I want to display patient.name,patient.age etc in the above html table fragment .I do not want to show the html table if the result set is empty. but I am not sure how to implement this in haml format.
Here is how I would do that. I assume here that you have your list of patients on the index view.
In your view :
In your
Patientcontroller:And in your model: