【发布时间】:2015-07-06 20:42:50
【问题描述】:
我一直在阅读 Rails 教程,https://www.railstutorial.org/book/static_pages,前两章很顺利。我在笔记本电脑上安装了 Rails,制作了一个 hello world 应用程序和一个带有脚手架生成器的玩具。有些事情我不得不做一些不同的事情,因为我在本地而不是在云环境中做所有事情,而且因为我使用的是 Windows 7,但我得到了一切工作。
当我尝试运行本地服务器并转到我的http://localhost:3000/static_pages/home 页面时,标题中出现错误。以下是完整的错误信息:
无法加载“active_record/connection_adapter/sqlite3_adapter”。确保 config/database.yml 中的适配器有效。如果您使用“mysql”、“mysql2”、“postgresql”或“sqlite3”以外的适配器,请将必要的适配器 gem 添加到 Gemfile。
我认为这一定是 Gemfile 的问题,因为这是此应用程序与我的其他应用程序之间的唯一区别,我只是不确定要更改什么。我包含了 Gemfile 和 database.yml。提前致谢。
#Gemfile - sample_app
source 'https://rubygems.org'
gem 'rails', '4.2.2'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'faker', '1.4.2'
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.8.0'
gem 'fog', '1.23.0'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'sqlite3'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '2.11.1'
end
数据库.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# 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:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
【问题讨论】:
-
你运行的是哪个版本的 Ruby?
-
从命令提示符中的 ruby -v 显示 ruby 2.1.5p273
-
你能在运行
bundle install时给我们一些输出吗? -
您是否成功地将 SQLite 与本教程中以前的 ruby 程序或示例一起使用? IOW,您如何测试 SQLite 是否正常工作以及您可以访问这些数据库? ([path-to-your-example-app]/db/development.sqlite3, [path-to-your-example-app]/db/test.sqlite3, and [path-to-your-example-app]/ db/production.sqlite3
-
本教程中前面的示例可以正常工作。所以我卸载了rails并重新安装。然后我使用了其他示例中的 gemfile,这似乎有效。我不明白这个问题,但它的工作。感谢您的帮助
标签: ruby-on-rails ruby windows