# Activerecord issue - all\_hashes error

**URL:** <https://www.ruby-forum.com/t/activerecord-issue-all-hashes-error/176061>\
**Category:** Rails\
**Created:** [September 24, 2009, 9:01am UTC](https://www.ruby-forum.com/t/activerecord-issue-all-hashes-error/176061 "2009-09-24T09:01:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgsfree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b487fb/32.png) [@cgsfree](https://www.ruby-forum.com/u/cgsfree)\
**Post date:** [September 24, 2009, 9:01am UTC](https://www.ruby-forum.com/t/activerecord-issue-all-hashes-error/176061/1 "2009-09-24T09:01:23Z")

</div>

Hi All,

I’m trying to run a simple Activerecord query (I’m still learning) but  
I’m running into a brick wall on the following error:

e[4;36;1mProduct Load (0.0ms)e[0m e[0;1mSELECT \* FROM `products`  
LIMIT 1e[0m  
(eval):3:in `each_hash': NULL pointer given (ArgumentError) from (eval):3:in`all\_hashes’  
from  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/connection\_adapters/mysql\_adapter.rb:605:in  
`select' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in`select\_all\_without\_query\_cache’  
from  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/connection\_adapters/abstract/query\_cache.rb:62:in  
`select_all' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:661:in`find\_by\_sql’  
from  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/base.rb:1548:in  
`find_every' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1505:in`find\_initial’  
from  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/base.rb:613:in  
`find’  
from C:/Documents and Settings/XYZ/My  
Documents/NetBeansProjects/XYZ/vendor/plugins/testing.rb:32

The code that generates this error is as follows:

* * *

require ‘mysql’  
require ‘activerecord’

# enable activerecord logging

ActiveRecord::Base.logger = Logger.new(STDERR)

# ActiveRecord connection

ActiveRecord::Base.establish\_connection(  
:adapter =\> “mysql”,  
:host =\> “localhost”,  
:username =\> “root”,  
:password =\> “pw”,  
:database =\> “etd”  
)

# old-school mysql connection

my = Mysql::real\_connect(“127.0.0.1”, “root”, “pw”, “etd”)

# create table and insert data

my.query “CREATE TABLE products (  
id int(11) NOT NULL auto\_increment,  
name varchar(255),  
PRIMARY KEY (id))”

my.query “INSERT INTO products VALUES(‘1’,‘brick’)”

# ActiveRecord class

class Product \< ActiveRecord::Base  
end

# Activerecord query

product\_row = Product.find(:first)

# Output result

puts product\_row.name

* * *

Note that I’ve included the create and insert statements for the  
convenience of anyone who may want to test this. Once the table and data  
are there you can remove these statements and the error still occurs.

Other platform/version details as follows:  
Box: Win32 (WinXP)  
Activerecord ver: 2.3.4  
IDE: Netbeans 6.7.1  
Mysql gem ver: 2.8.1

Any help or suggestions on how to fix this would be greatly appreciated.

Regards,

Andre

---

<div class="post-metadata">

**Author:** ![cgsfree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b487fb/32.png) [@cgsfree](https://www.ruby-forum.com/u/cgsfree)\
**Post date:** [September 25, 2009, 1:20am UTC](https://www.ruby-forum.com/t/activerecord-issue-all-hashes-error/176061/2 "2009-09-25T01:20:18Z")

</div>

If anyone is interested, I found a solution to this problem.

See here:  
[http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407](http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407)

Looks like MySQL 5.1 client library doesn’t play well with Rails.

Andre
