ActiveRecord::ConnectionNotEstablished

Hey, I im using Rails 3.2.3 for my app, and everything its ok when I run rails s.

But when I go to the browser i got this:

ActiveRecord::ConnectionNotEstablished

And this is the full trace:

activerecord (3.2.3) lib/activerecord/connection_adapters/abstract/ connection_pool.rb:398:in retrieve_connection' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/ connection_specification.rb:168:inretrieve_connection' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/ connection_specification.rb:142:in connection' activerecord (3.2.3) lib/active_record/query_cache.rb:67:inrescue in call' activerecord (3.2.3) lib/active_record/query_cache.rb:61:in call' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/ connection_pool.rb:467:incall' actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (3.2.3) lib/active_support/callbacks.rb: 405:in_run4231786738375313579call1989705551904492368_callbacks' activesupport (3.2.3) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.3) lib/active_support/callbacks.rb: 385:in_run_call_callbacks' activesupport (3.2.3) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb: 27:incall' actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in call' actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb: 31:incall' actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb: 16:in call' actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb: 56:incall' railties (3.2.3) lib/rails/rack/logger.rb:26:in call_app' railties (3.2.3) lib/rails/rack/logger.rb:16:incall' actionpack (3.2.3) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.1) lib/rack/methodoverride.rb:21:incall' rack (1.4.1) lib/rack/runtime.rb:17:in call' activesupport (3.2.3) lib/active_support/cache/strategy/local_cache.rb: 72:incall' rack (1.4.1) lib/rack/lock.rb:15:in call' actionpack (3.2.3) lib/action_dispatch/middleware/static.rb:62:incall' railties (3.2.3) lib/rails/engine.rb:479:in call' railties (3.2.3) lib/rails/application.rb:220:incall' rack (1.4.1) lib/rack/content_length.rb:14:in call' railties (3.2.3) lib/rails/rack/log_tailer.rb:14:incall' rack (1.4.1) lib/rack/handler/webrick.rb:59:in service' /Users/VictorHugo/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/webrick/ httpserver.rb:111:inservice' /Users/VictorHugo/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/webrick/ httpserver.rb:70:in run' /Users/VictorHugo/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/webrick/ server.rb:183:inblock in start_thread'

And this is my database.yml

# SQLite version 3.x # gem install sqlite3-ruby (not necessary on OS X Leopard) development:   adapter: mysql   encoding: utf8   reconnect: false   database:   pool: 5   username: root   password:   socket: /tmp/mysql.sock

# Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. development:   adapter: mysql   encoding: utf8   reconnect: false   database:   pool: 5   username: root   password:   socket: /tmp/mysql.sock

And I really dont know what it can be :confused: Thx guys

Hey, I im using Rails 3.2.3 for my app, and everything its ok when I run rails s.

But when I go to the browser i got this:

ActiveRecord::ConnectionNotEstablished

And this is the full trace:

activerecord (3.2.3) lib/activerecord/connection_adapters/abstract/ connection_pool.rb:398:in retrieve_connection' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/ connection_specification.rb:168:inretrieve_connection' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/ connection_specification.rb:142:in connection' activerecord (3.2.3) lib/active_record/query_cache.rb:67:inrescue in call' activerecord (3.2.3) lib/active_record/query_cache.rb:61:in call' activerecord (3.2.3) lib/active_record/connection_adapters/abstract/ connection_pool.rb:467:incall' actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (3.2.3) lib/active_support/callbacks.rb: 405:in_run4231786738375313579call1989705551904492368_callbacks' activesupport (3.2.3) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.3) lib/active_support/callbacks.rb: 385:in_run_call_callbacks' activesupport (3.2.3) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb: 27:incall' actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in call' actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb: 31:incall' actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb: 16:in call' actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb: 56:incall' railties (3.2.3) lib/rails/rack/logger.rb:26:in call_app' railties (3.2.3) lib/rails/rack/logger.rb:16:incall' actionpack (3.2.3) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.1) lib/rack/methodoverride.rb:21:incall' rack (1.4.1) lib/rack/runtime.rb:17:in call' activesupport (3.2.3) lib/active_support/cache/strategy/local_cache.rb: 72:incall' rack (1.4.1) lib/rack/lock.rb:15:in call' actionpack (3.2.3) lib/action_dispatch/middleware/static.rb:62:incall' railties (3.2.3) lib/rails/engine.rb:479:in call' railties (3.2.3) lib/rails/application.rb:220:incall' rack (1.4.1) lib/rack/content_length.rb:14:in call' railties (3.2.3) lib/rails/rack/log_tailer.rb:14:incall' rack (1.4.1) lib/rack/handler/webrick.rb:59:in service' /Users/VictorHugo/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/webrick/ httpserver.rb:111:inservice' /Users/VictorHugo/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/webrick/ httpserver.rb:70:in run' /Users/VictorHugo/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/webrick/ server.rb:183:inblock in start_thread'

And this is my database.yml

# SQLite version 3.x # gem install sqlite3-ruby (not necessary on OS X Leopard) development: adapter: mysql encoding: utf8 reconnect: false database:

It might be helpful to tell it which database to use. I don't understand how rake db:create or db:migrate worked with this file.

Colin

Use mysql2 gem for 3x version of rails instead of mysql

Were you able to solve the issue? I am getting the exact same error and I using the mysql2 gem. I also have the database name in database.yml.

It seems likely the OP realised he was doing something silly and was too embarrassed to post back here.

Are you able to access the database using mysql command line or similar tool?

Are you able to create the db ok using rake db:create If not copy and paste the result here.

Colin

Thanks Colin. Your response actually helped solved the problem. I started having the issue after I upgraded to Rails 3.2.3. I tried to create a new database using rake db:create (as you suggested) and it showed me that the problem was a version difference between MySQL and the client used by rails. The following article helped me solve the problem:

http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

Thanks again,

Fernando.