views:

789

answers:

3

I came in this morning, fired up my app in the same way as usual, and started getting this error. Since then, I have been down every road I can conceive - to the point of removing and reinstalling every piece of ruby/rails software on my machine, including mysql. I have stripped my application down to just the following.

require 'rubygems'
require 'active_record'

class Job < ActiveRecord::Base

end

ActiveRecord::Base.establish_connection(
    :adapter     => "mysql",
    :host        => "192.168.254.22",  (I've also tried 127.0.0.1)
    :port        => "3306",
    :database    => "databasethingie",
    :username    => "root",
    :password    => "rootpassword"
)

job = Job.find(:first) This is on a windows box running instant rails 2.0.

I still get the errors:

c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/mysql_adapter.rb:505:in `real_connect': can't convert String into Integer (TypeError)
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/mysql_adapter.rb:505:in `connect'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/mysql_adapter.rb:183:in `initialize'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `new'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `mysql_connection'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in `send'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in `connection='
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:260:in `retrieve_connection'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2693:in `quoted_table_name'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1469:in `construct_finder_sql'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1341:in `find_every'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1303:in `find_initial'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:534:in `find'
        from tmp.rb:17

I've seen posts about this that refer to a bug that was fixed way back in 1.5.2 days, but I'm up-to-date. 2.1.2, etc. What is going on here? I had wondered if this was related to recent changes to the database configuration (granting full rights to root) but the reinstall would seem to prove otherwise.

+2  A: 

Did you try:

:port => 3306
Robert Gamble
A: 

Okay, how the hell did you spot that? That line had not changed in about 6 weeks - I've double-checked. Why would this have suddenly become a problem?

I used :port once and seem to remember using an integer. Given the error message and the fact that this was the only thing in your connection call that was numeric it seemed like a reasonable thing to try.
Robert Gamble
A: 

Same thing here, thx for the solution, I had a hunch it would be my sql port but dismissed the idea because that piece of code used to work fine. The thing that changed however is that I moved to the mysql gem instead of the mysql code that used to ship with rails (not anymore since 2.2)