Search comma separated values db column in Rails
I wanted to search for a value in DB and the column data is comma separated values say …
foo,bar,hey,hay
Now I wanted to find a record based on the value …say …hay
MySQL’s FIND_IN_SET comes into play and it works as follows
1 2 3 | <% Model.find(:first, :conditions => ["FIND_IN_SET(?,search_column)", search_string]) %> |
Hope this helps!

