We will create a page that will allow us to filter all the records based on company and gender, and then use the find command to show the filtered results on the next page.
We will follow these steps to create the page:
Create a link for filter page on the home page i.e.
index.erb
in the app folder:<li> <a href="<%= url_for :controller => :Employee, :action => :filter_employee_form %>"><span class="title"> Filter Employee </span><span class="disclosure_indicator"/></a> </li>
We can see in the screenshot that a Filter Employee link is created on the home page.
Create an action
filter_employee_form
inemployee_controller.rb
:def filter_employee_form @companies = Company.find(:all) end
We have used the find helper provided by Rhom that will retrieve all the companies and store them in
@companies
.Create a page
filter_employee_form.erb
in theapp/Employee
folder and write...