Albacheeser
Albacheeser

Reputation: 1

ActiveRecord::ConnectionNotEstablished - R.o.R. 3 with code migrated from a 2.x system

I have a situation I have been beating my head against the wall over. First, I am not a Ruby/Rails person but I am a developer. I know only the most basic information about it but I have to get this code going on this server.

It is a Windows 2008 64-Bit server with Rails & Ruby 1.9.3. Rails seems to function normally with imports and the documentation server works, etc. However, when I attempt to run the site code in its "server" I get the ConnectionNotEstablished error.

I have also installed the MySQL connector and installed the MySQL binding although I thought it was built in. Doesn't seem to work either way.

I need either a fix or more information on how I can get more information than ActiveRecord::ConnectionNotEstablished. If I can get to more trace info I can troubleshoot if further but I just don't know what to try next because I don't have enough information so I am stuck trying random things.

Now, here is what I have got:

Rails install folder: c:\RailsInstaller with a C:\RailsInstaller\Ruby1.9.3 folder where Ruby is.

DEFAULT SITE WORKS - Site folder: c:\sites\quote_machine and when I run c:\sites\quote_machine\rail s in this folder the server loads without error and the "Welcome Aboard" screen comes up.

database.yml:

development:
  adapter: mysql
  database: fb
  host: localhost
  port: 3306
  username: ******
  password: ********
  timeout: 5000

(also there is a test & production section)

Here is the syntax of one of the table db models:

incident_group.rb

class IncidentGroup < ActiveRecord::Base
  set_table_name "incident_group"
  set_primary_key "group_id"
   belongs_to :prospect, :class_name => "Prospect", :foreign_key => "prospect_id"
   has_many :incidents, :class_name => "Incident", :foreign_key => "group_id"
end

incident.rb

class Incident < ActiveRecord::Base
  set_table_name "incident"
  set_primary_key "incident_id"
  belongs_to :incident_group, :class_name => "IncidentGroup", :foreign_key => "group_id"
end

Other important facts:

  1. The database is up and works fine directly and with Coldfusion on that same server so there is nothing wrong with the database. Moreover, when I manually connect to the database using the IRB it appears to connect.
  2. The site worked fine when it was on a Linux server running Rails 2.x
  3. The URL routing is correct and running the running the correct controllers and views as far as I can tell.
  4. I have tried different syntax variations with no change in result so I just need help on where I can get more error information. By the way the "Trace" does not really tell me anything.

Upvotes: 0

Views: 150

Answers (1)

Naveen Agarwal
Naveen Agarwal

Reputation: 579

Try changing the database.yml file first. change the adapter value to "mysql2" and in your gem file make sure you are using "mysql2" gem instead of "mysql".

Upvotes: 1

Related Questions