使用PG进行ROR

时间:2015-04-23 04:56:58

标签: ruby-on-rails ruby postgresql

我在我的应用程序中使用pg

这是database.yml文件

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: testing_development

# 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

当我跑rake db:create时,这就是我所得到的:

PG::SyntaxError: ERROR:  syntax error at or near "."
LINE 1: CREATE DATABASE "db/test"."sqlite3" ENCODING = 'utf8'
                             ^
: CREATE DATABASE "db/test"."sqlite3" ENCODING = 'utf8'

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:4)

运行rake db:create时,它会尝试为您创建所有数据库,因此您需要正确命名testproduction数据库。数据库名称不能包含句点。

即,如果您的应用程序名称为testing

test:
  <<: *default
  database: testing_test

production:
  <<: *default
  database: testing_production