Skip to content

Conversation

@shhavel
Copy link

@shhavel shhavel commented Jul 4, 2012

For such cases

categories = [
{ id: 1679, name: "Cooking" },
{ id: 8140, name: "COOKING > BICOOKING" },
{ id: 8130, name: "COOKING > BIHOBS" }
]

One method changed only: find_item(tmp_name)

Or can use case insensitive search
if normal search gives no results

def find_item(tmp_name)
tmp_name = tmp_name.to_s.strip
@Items.find do {|item| item.name == tmp_name } || @Items.find do {|item| item.name.downcase == tmp_name.downcase }
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant