Reputation: 4730
So I know how to check if a query is a substring of a field:
where("field like ?", query)
But how would I do it in reverse? So that it checks if a field is a substring of the query?
E.g. if I have objects:
[123,45,678]
I want to know which ones occur in the number:
45678
= [45,678]
My current solution is:
mer = []
Mer14.find_each do |m|
if query.include?(m.sequence)
mer << m
end
But I'm not sure if this is efficient or ideal!
Upvotes: 1
Views: 582