Need to somehow match a phrase in comparison to a hash and grab the id:
Hash:
h = [{'id' => '1', 'words' => 'blue table stand'}, {'id' => '2', 'words' => 'red table stand'}]
Word:
search = 'stand blue'
I would like to return the ids of those that has the words ‘stand’ and ‘blue’ so that I get back the id number 1. Thanks.
I agree with @sawa that the data doesn’t seem to be formed in the most comfortable manner, but you never know where it came from…
Anyway, this should work:
From the comments below, using the [] accessor on the string makes this shorter, and I hate scroll bars enough to update it: