Rails: Sqlite with the Pearl of PG

I installed postgres on my Mac and tried Rails for the first time. I turned on the gem "pg" and removed the sqlite3 stone (in the end, why do you need the latter if you use the first). However, when I tried to start the server, I received this error message

.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)

So, I turned on the sqlite3 pearl again, and now the server is working fine, but I really have no idea if my test application uses sqlite3 or pg?

a) Do I assume that the sqlite3 monster is installed if I plan to use pg pearls? b) If I have only one of the two installed, is there a way to find out which one uses the test application (since both of them are in the 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'
+5
source share
3

database.yml, pg gem, postgresql, , , ( , ):

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:
+10

- Gemfile

, sqlite pg Gemfile.

gem 'sqlite3'

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

, sqlite3 , pg, database.yml , .

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

production:
  adapter: pg (please correct the adapter)
  database: 
  user:
  password:

,

+3

A) , sqlite3 , pg?

, , sqlite sqlite pg postgres

B) , , ( Gemfile)

. : rails db . postgres:

$rails db
psql (9.1.2)
Type "help" for help.

C) : " ?"

In fact, there are several scenarios in which you need and which include some existing data in one db in another, converting an application from one to another, etc. True, usually one or the other.

+1
source

All Articles