Problem using ActiveRecord on Windows

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!

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

On May 4, 11:40 am, Shane C. [email protected]

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. [email protected]

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs