[Ruby] Rails fuzzy search function implementation

less than 1 minute read

WHY

I was studying how to implement a search function using the LIKE clause and the Where method. .. .. However, the explanation of the level that can be actually moved on the site is Nothing. Probably I’m not good at applying it, but I’ve managed to row until the implementation this time, so I will write down the steps here!

STEP

(1) Create a search action and add form_tag to the corresponding html. Here, it is extremely important to set a value in text_field (value is stored in params)

(2) Write code that uses the LIKE clause and where method in the index action. (Keyword is the value defined in text_field) Store it in an instance method. ③ After that, use each statement or partial template and display the search results in a list!