Ahmad hayat Ahmad hayat - 1 year ago 70
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")

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download