Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在ruby on rails上实现postgresql时出错_Ruby On Rails_Database_Ruby On Rails 3_Postgresql - Fatal编程技术网

Ruby on rails 在ruby on rails上实现postgresql时出错

Ruby on rails 在ruby on rails上实现postgresql时出错,ruby-on-rails,database,ruby-on-rails-3,postgresql,Ruby On Rails,Database,Ruby On Rails 3,Postgresql,我在实现rake数据库时遇到以下错误:migrate rake aborted! Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) 我使用postgresql在数据库中创建了两个表 我的database.yml是 development: adapter: postgre

我在实现rake数据库时遇到以下错误:migrate

rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
我使用postgresql在数据库中创建了两个表

我的database.yml是

development:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: shop_development
  pool: 5
  username: postgres
  password: 

test:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: shop_test
  pool: 5
  username: postgres
  password: 

production:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: shop_production
  pool: 5
  username: postgres
  password: 
我还运行了以下命令:

C:\Sites\shop>gem install 'pg'
Successfully installed pg-0.14.1-x86-mingw32
1 gem installed
Installing ri documentation for pg-0.14.1-x86-mingw32...
Installing RDoc documentation for pg-0.14.1-x86-mingw32...
但这仍然给了我同样的错误

我的文件包含以下内容:

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.11)
      actionpack (= 3.2.11)
      mail (~> 2.4.4)
    actionpack (3.2.11)
      activemodel (= 3.2.11)
      activesupport (= 3.2.11)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activemodel (3.2.11)
      activesupport (= 3.2.11)
      builder (~> 3.0.0)
    activerecord (3.2.11)
      activemodel (= 3.2.11)
      activesupport (= 3.2.11)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.11)
      activemodel (= 3.2.11)
      activesupport (= 3.2.11)
    activesupport (3.2.11)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    arel (3.0.2)
    builder (3.0.4)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.4.0)
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    hike (1.2.1)
    i18n (0.6.1)
    journey (1.0.4)
    jquery-rails (2.2.1)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.7.6)
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.21)
    multi_json (1.5.0)
    polyglot (0.3.3)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.11)
      actionmailer (= 3.2.11)
      actionpack (= 3.2.11)
      activerecord (= 3.2.11)
      activeresource (= 3.2.11)
      activesupport (= 3.2.11)
      bundler (~> 1.0)
      railties (= 3.2.11)
    railties (3.2.11)
      actionpack (= 3.2.11)
      activesupport (= 3.2.11)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (10.0.3)
    rdoc (3.12.1)
      json (~> 1.4)
    sass (3.2.5)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.7-x86-mingw32)
    thor (0.17.0)
    tilt (1.3.3)
    treetop (1.4.12)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.35)
    uglifier (1.3.0)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  coffee-rails (~> 3.2.1)
  jquery-rails
  rails (= 3.2.11)
  sass-rails (~> 3.2.3)
  sqlite3
  uglifier (>= 1.0.3)
my bundle安装显示以下内容:-

C:\Sites\shop>bundle install
Using rake (10.0.3)
Using i18n (0.6.1)
Using multi_json (1.5.0)
Using activesupport (3.2.11)
Using builder (3.0.4)
Using activemodel (3.2.11)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.2.2)
Using actionpack (3.2.11)
Using mime-types (1.21)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.11)
Using arel (3.0.2)
Using tzinfo (0.3.35)
Using activerecord (3.2.11)
Using activeresource (3.2.11)
Using bundler (1.0.22)
Using coffee-script-source (1.4.0)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Using json (1.7.6)
Using rdoc (3.12.1)
Using thor (0.17.0)
Using railties (3.2.11)
Using coffee-rails (3.2.2)
Using jquery-rails (2.2.1)
Using pg (0.14.1)
Using rails (3.2.11)
Using sass (3.2.5)
Using sass-rails (3.2.6)
Using uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem
is installed.

您是否已运行
捆绑安装

看起来当前安装了
sqlite3
,但
pg
没有

如果要将数据从
sqlite3
移动到
pg
,请查看此railscast:

请尝试使用此

 sudo apt-get install postgresql postgresql-client postgresql-contriblibpq-dev

你能把你的Gemfile添加到问题中吗?@jvnill我已经编辑了这个问题。你能帮我修改一下我的Gemfile.lock吗。Gemfile比较干净,所以你可以用它来代替吗?嗨,Prathamesh,我已经清理了你的一些代码格式,但是请看一下格式指南,它会让你的问题更容易阅读:我的Gemfile有以下内容:-源代码“gem”rails、“3.2.11”#而不是Bundle edge rails:#gem“rails”,:git=>'git://github.com/rails/rails.git“gem”sqlite3“#默认情况下,gem仅用于资产,在生产环境中不需要。组:资产做gem'sass-rails',“~>3.2.3”gem'coffee-rails',“~>3.2.1”#有关更多支持的运行时gem'uglifier',“>=1.0.3”end-gem'jquery-rails'是的,我已运行bundle安装C:\Sites\shop>bundle安装。。。您的包已完成!使用
bundle show[gemname]
查看捆绑gem的安装位置。如何从ruby on rails命令启动postgresql控制台promptI可以在gem文件中查看gem,但不在您发布的已安装宝石列表中。@mind.blank我已经用已安装宝石列表编辑了我的问题,请告诉我是否有需要添加的宝石。不确定。顺便问一下,为什么您的数据库都在开发?@vijikumar谢谢,现在它正在工作。您能告诉我如何在ruby on rail中启动postgresql控制台吗?您能指定命令吗
 sudo apt-get install postgresql postgresql-client postgresql-contriblibpq-dev