1

Rails 3.2.11を実行していますが、これは3.2.10と3.2.9でも発生するようです。基本的に、私はします

rails new sample_app
rails console

そしてこれは吐き出します:

/Users/carl/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) (LoadError)
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:7:in `<top (required)>'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activerecord-3.2.11/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activerecord-3.2.11/lib/active_record/base.rb:720:in `<top (required)>'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/activerecord-3.2.11/lib/active_record/railtie.rb:41:in `block in <class:Railtie>'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/railtie.rb:179:in `call'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/railtie.rb:179:in `block in load_console'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/railtie.rb:179:in `each'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/railtie.rb:179:in `load_console'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/engine.rb:429:in `block in load_console'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/railties.rb:8:in `each'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application/railties.rb:8:in `all'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/engine.rb:429:in `load_console'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/application.rb:153:in `load_console'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/commands/console.rb:27:in `start'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /Users/carl/.rvm/gems/ruby-1.9.3-p362@rails3tutorial2ndEd/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

私の質問は、デフォルトで生成されたGemfileを使用しており、postgresも使用していないということです。Railsが私に不満を言っているのはなぜですか?どうすれば修正できますか?それは私のgemsetまたはRubyGemsと関係があるのでしょうか?参考のためにGemfileを次に示します。

source 'https://rubygems.org'
gem 'rails', '3.2.11'
# 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', :platforms => :ruby
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'

これは私の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
4

2 に答える 2

2

config/database.yml で postgresql が指定されていないことを確認してください。代わりに、優先データベースを使用する必要があります。

つまり、新しい Rails アプリケーションのデフォルトは sqlite にする必要があります。

于 2013-01-09T03:30:46.263 に答える