How can you add simple search form to rails project ?
You want to add search form, but you don’t no. HOW?
Let’s start, firstly you should use ransack and
will_paginate gems in your
Gemfile then you should write in
Then open controller which you want to add search bar, like ;
@search = Project.search(params[:q])
@project = @search.result(distinct: true).paginate(:page => params[:page])
When you added controller, you should add below code which relation to index file ;
= search_form_for @search do |f|
= f.label :name_cont
= f.search_field :name_cont
That’s all .
I hope helped to you .