Ahmad hayat Ahmad hayat - 7 months ago 32
Ruby Question

Search result is not displaying

I have an issue in searching records from the PostgreSQL with particular search keyword but no record is displaying here is the code

@outputs = Output.where("name LIKE '%#{filter_text}%'").order("name ASC")


If you use ransack gem, it will allow you use simple methods to search. Using ransack, you will only need to do this:

@outputs = Output.search(name_cont: params[:filter_search]).result.order("name ASC")

Hope it solves your problem.