Fresh version of OS X Ruby on Rails, not related to database connection
I will provide my specifications:
- RVM 1.12.1
- Rails 3.2.3
- Ruby 1.9.3p125 (2012-02-16 version 34643) [x86_64-darwin12.0.0]
- RubyGem 1.8.21
- OS X 10.8 Mountain Lion
- Kenneth Reitz GCC Installer for OSX 10.7+ Version 2 (includes X11 headers, patches)
My Gemfile looks like this:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
And my database.yml:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
When I started the server and went to the default home page and clicked the "viewer" button, I get the "ActiveRecord :: ConnectionNotEstablished" error.
When I check the console I see:
/Users/username/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.3/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem': Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.) (LoadError)
from /Users/username/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/activerecord-3.2.3/lib/active_record/connection_adapters/mysql_adapter.rb:5:in `<top (required)>'
from /Users/username/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /Users/username/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/username/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/username/.rvm/gems/ruby-1.9.3-p125@rails3tutorial2ndEd/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
Even though I am using SQLite and that there is no MySQL reference in MySQL. Could this be a side effect of some use of 10.8? I'm stumped!
source to share
Several months ago I was working on a project using java and Play! Framework, and we used an environment variable called DATABASE_URL to easily manage database configuration during development and production. In my case, the variable was set to mysql://root@localhost:3306/database_name
.
As it turns out, rails 3.2
trying to get the database configuration from an environment variable called DATABASE_URL.
Here is the code on rail 3.2:
The same method for the rails 3.1 branch:
So, I just removed the environment variable and everything is fine.
source to share