Rails:带有PG gem的Sqlite

Lea*_*cim 5 sqlite postgresql ruby-on-rails rails-postgresql

我在Mac上安装了postgres并且第一次使用Rails进行了尝试.我包含了gem"pg"并删除了sqlite3 gem(毕竟,如果使用前者,为什么还需要后者).但是,当我尝试启动服务器时,我收到此错误消息

.rvm/gems/ruby-1.9.3-rc1@rails321/gems/bundler-1.0.22/lib/bundler/rubygems_integration.rb:143:in `block in replace_gem': Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.) (LoadError)
Run Code Online (Sandbox Code Playgroud)

所以我再次包含sqlite3 gem,现在服务器工作正常,但我实际上不知道我的测试应用程序是否使用sqlite3或pg?

a)如果我打算使用pg gem,我是否应该安装sqlite3 gem?b)如果我只应该安装两个中的一个,有没有办法找出我的测试应用当前正在使用哪一个(因为它们都在Gemfile中)

的Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'pg'
gem 'devise'
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'

  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 web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
Run Code Online (Sandbox Code Playgroud)

Ale*_*ant 10

这是我的database.yml,当我使用pg gem时,适配器实际上称为postgresql,并且设置中还有其他一些差异,如果你只是复制并粘贴下面的代码并更改数据库名称你应该很漂亮准备好了(我使用了heroku,这在那里工作):

development:
  adapter: postgresql
  encoding: utf8
  reconnect: false
  database: DATABASE_DEVELOPMENT
  pool: 5
  username: USER_NAME
  password:
  host: localhost

test:
  adapter: postgresql
  encoding: utf8
  reconnect: false
  database: DATABASE_TEST
  pool: 5
  username: USER_NAME
  password:
  host: localhost

production:
  adapter: postgresql
  encoding: utf8
  reconnect: false
  database: DATABASE_PRODUCTION
  pool: 5
  username: root
  password:
Run Code Online (Sandbox Code Playgroud)