From: Rodrigo Lueneberg Date: 2013-06-29T03:01:05+09:00 Subject: Re: Find elment in array of hashes Thanks, I tried your code but I keep getting nil, but I know for sure that the value "3" is in there. sql = "SELECT p.id, s.price FROM services s inner join products as p ON s.product_id = p.id where s.shop_id = 1" r = ActiveRecord::Base.connection.select_all(sql) @array = r.find {|k,v| k[:id] == "3"} if I change it to @array = r.find {|k,v| v[:id] == "3"} I get undefined method `[]' for nil:NilClass -- Posted via http://www.ruby-forum.com/.