克隆GitHub项目后ActiveRecord :: ConnectionNotEstablished?

时间:2013-09-04 20:32:09

标签: ruby-on-rails activerecord

我最近在更换机器后克隆了我在GitHub上的项目,我运行了bundle install并启动了本地服务器,得到了这样的消息:

ActiveRecord::ConnectionNotEstablished

谷歌搜索后,我手动创建了一个database.yml文件,并输入了以下信息:

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# 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.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

并运行rake db:create和rake db:migrate但我仍然收到错误,有人可以提出任何建议吗?

BTW,这是我的Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.14'
gem 'jquery-rails', '2.0.2'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.11.0'
  gem 'guard-rspec', '1.2.1'
  gem 'guard-spork', '1.2.0'
  gem 'childprocess', '0.3.6'
  gem 'spork', '0.9.2'
end

group :test do
  gem 'capybara', '1.1.2'
  gem 'rb-fchange', '0.0.5'
  gem 'rb-notifu', '0.0.4'
  gem 'win32console', '1.3.0'
  gem 'factory_girl_rails', '4.1.0'
  gem 'cucumber-rails', '1.2.1', :require => false
  gem 'database_cleaner', '0.7.0'
end

group :development do
  gem 'annotate', '2.5.0'
end

group :production do
  gem 'pg', '0.12.2'
end

group :assets do
  gem 'sass-rails',   '3.2.5'
  gem 'coffee-rails', '3.2.2'
  gem 'uglifier', '1.2.3'
end

1 个答案:

答案 0 :(得分:1)

运行数据库迁移:

# from command line
rake db:migrate

然后,如果有db/seeds.db文件,您可以使用它来为您的数据库设定种子:

rake db:seed