【问题标题】:Ruby on Rails- ActiveRecord::ConnectionNotEstablished on localhost:3000Ruby on Rails-ActiveRecord::ConnectionNotEstablished on localhost:3000
【发布时间】:2013-06-09 01:04:04
【问题描述】:

我是一名 Ruby on Rails 初学者,学习在线书籍 Ruby on Rails Tutorial。当我做bundle updatebundle install 然后rails server

当我连接到 localhost:3000/ 时,我得到以下图像:http://i.imgur.com/2RrImWs.png 我使用的 GemFile 有这样的内容:

    source 'http://rubygems.org'

    gem 'rails', '3.1.1'

    gem 'sqlite3'

    group :development do
      gem 'rspec-rails', '2.6.1'
    end


    group :test do
      gem 'rspec-rails', '2.6.1'
      gem 'webrat', '0.7.1'
    end

    group :assets do
      gem 'sass-rails',   '~> 3.1.4'
      gem 'coffee-rails', '~> 3.1.1'
      gem 'uglifier', '>= 1.0.3'
    end

    gem 'jquery-rails'

更新:Database.yml 文件如下所示

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
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

本地主机页面上的完整跟踪提供以下输出:

activerecord (3.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in `retrieve_connection'
activerecord (3.1.1) lib/active_record/connection_adapters/abstract/connection_specification.rb:107:in `retrieve_connection'
activerecord (3.1.1) lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
activerecord (3.1.1) lib/active_record/query_cache.rb:65:in `rescue in call'
activerecord (3.1.1) lib/active_record/query_cache.rb:59:in `call'
activerecord (3.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.1) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.1) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.10) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.1) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.10) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.10) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.10) lib/rack/lock.rb:15:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.1) lib/rails/engine.rb:456:in `call'
railties (3.1.1) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.10) lib/rack/handler/webrick.rb:59:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

【问题讨论】:

  • 你的 config/database.yml 文件是什么样的?
  • 确保已安装 sqlite3
  • 更新为包含 database.yml。以及如何安装 sqlite3?
  • 请将文本错误信息粘贴到您的问题中,以便对其他人有所帮助,并删除屏幕截图。
  • 你做了 rake db:create 吗?在控制台中运行sqlite3 时看到了什么?

标签: ruby-on-rails ruby


【解决方案1】:

在 Gemfile 的 development: 部分中添加行 gem 'sqlite3', '1.3.5'。然后运行bundle install

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-23
    • 2015-02-22
    • 2015-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多