Make a note of how to search by multiple values with LIKE.
gem 'activerecord-like'
It's easier to do with, but I've implemented it as an alternative.
scope = User.all
names = ['yama', 'mae']
search_sql = []
names = names.map do |n|
search_sql.push('name like ?')
"%#{name}%"
end
scope = scope.where( search_sql.join(' or '), *names )
Recommended Posts