# Problem using ActiveRecord on Windows

**URL:** <https://www.ruby-forum.com/t/problem-using-activerecord-on-windows/167155>\
**Category:** Rails\
**Created:** [May 4, 2009, 8:40pm UTC](https://www.ruby-forum.com/t/problem-using-activerecord-on-windows/167155 "2009-05-04T20:40:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skiloup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@skiloup](https://www.ruby-forum.com/u/skiloup)\
**Post date:** [May 4, 2009, 8:40pm UTC](https://www.ruby-forum.com/t/problem-using-activerecord-on-windows/167155/1 "2009-05-04T20:40:39Z")

</div>

## Problem

ActiveRecord appears to be failing on my Windows install

## Setup

I have MySql version 5.0.51 running on a debian box, let’s call it (A)  
I have Ruby w/ the ActiveRecord gem installed on an ubuntu box, let’s  
call it (B)  
I have Ruby w/ the ActiveRecord and mysql gems installed on a Windows  
box, let’s call it ©

## Scenario

I have a simple table named ‘Software’ in a database named ‘master’ on  
(A).

I have written a dirt simple script to show me all of the records in the  
‘Software’ table.

Here it is:  
`
require ‘rubygems’
require ‘activerecord’
require ‘pp’`

class Software \< ActiveRecord::Base  
set\_table\_name “Product” # Not “Softwares”  
end

ActiveRecord::Base.establish\_connection(  
:host =\> “deb”,  
:adapter =\> “mysql”,  
:database =\> “master”,  
:username =\> “username”, # this is not my real username  
:password =\> “password”, # this is not my real password  
:autocommit =\> true  
)

pp Software.find(:all)

(B) executes properly without any problems, however © fails to execute  
with the following dump…

`
(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.2/lib/active_record/connection_adapters/mysql_adapter.rb:596:in
`select'
  from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/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.2/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.2/lib/active_record/base.rb:661:in
`find_by_sql'
  from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1553:in
`find_every'
  from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:615:in
`find'
  from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1905:in
`find_all_by_Product_Name'
  from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1890:in
`send'
  from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1890:in
`method_missing'
  from simpleConnectMySql.rb:24 -- this is my simple script
`

Any help would be greatly appreciated. Like I said I’m new to this  
ActiveRecord stuff, so it could be a very simple problem. I’m just  
confused because it works perfectly on my ubuntu machine (B).

Thanks guys!

---

<div class="post-metadata">

**Author:** ![skiloup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@skiloup](https://www.ruby-forum.com/u/skiloup)\
**Post date:** [May 4, 2009, 9:01pm UTC](https://www.ruby-forum.com/t/problem-using-activerecord-on-windows/167155/2 "2009-05-04T21:01:26Z")

</div>

What is the primary key in the Product table? Is it ‘id’ or something  
else?

On May 4, 11:40 am, Shane C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![skiloup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@skiloup](https://www.ruby-forum.com/u/skiloup)\
**Post date:** [May 4, 2009, 9:49pm UTC](https://www.ruby-forum.com/t/problem-using-activerecord-on-windows/167155/3 "2009-05-04T21:49:24Z")

</div>

E. Litwin wrote:

> What is the primary key in the Product table? Is it ‘id’ or something  
> else?
> 
> On May 4, 11:40ï¿½am, Shane C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

It’s actually ‘Software ID’, but I tried defining my class as follows  
with the same results:

class Software \< ActiveRecord::Base  
set\_table\_name “Product” # Not “Softwares”  
set\_primary\_key “Software ID”  
end
