WHY I was investigating how to implement a search function using the LIKE clause and the Where method. .. .. However, the explanation of the level that can actually be moved on the site is nothing. I think I'm not good at applying it, but I managed to implement it this time, so I'll write down the steps here!
STEP ① Create a search action and add form_tag to the corresponding html. Here, it is extremely important to set a value in text_field (the value is stored in params)
(2) Write code using the LIKE clause and where method in the index action. (Keyword is the value specified by text_field) Store it in an instance method. ③ After that, display the search results in a list by using the each statement or the partial template!
Recommended Posts