I know how it works include?, but it's not entirely clear using it with a multidimensional array or hash (is this possible with a hash?)
For example, if I have a hash that looks like this:
@user.badges => [{:id => 1, :name => 'blahh', :description => 'blah blah blah'}, {:id => 2, :name => 'blahh', :description => 'blah blah blah'}]
Can I see if it has an object with id 1 in it?
if @user.badges.include?(:id => 1)
end
It doesn't seem to work, how can I write this method correctly?
source
share