Reputation: 6660
I get my hash using this :
@hotels = Hotel.all
it returns : [Hotel1, Hotel2...]
How can i extract from this hash the Hotel id=10 for example?
Thank you for help.
Upvotes: 0
Views: 2887
Reputation: 20125
To find a single element from the Array:
@hotels.find { |h| h.id == 10 }
#=> Hotel10
You might be better off doing Hotel.find(10) instead, though.
Upvotes: 2