简体   繁体   English

尝试运行服务器时,Ruby on Rails postgres适配器错误

[英]Ruby on Rails postgres adapter error when trying to run the server

I have installed all the gems that I saw listed in How to handle Ruby on Rails error: "Please install the postgresql adapter: `gem install activerecord-postgresql-adapter'" - none of them work. 我已经安装了我在如何处理Ruby on Rails中列出的所有宝石错误:“请安装postgresql适配器:`gem install activerecord-postgresql-adapter'” - 它们都不起作用。 It doesn't matter if I have postgres or postgresql in my databases.yml file. 如果我在databases.yml文件中有postgres或postgresql并不重要。

I have no clue what I am doing wrong (I also installed the driver mentioned in the error as well. I keep getting that error. 我不知道我做错了什么(我也安装了错误中提到的驱动程序。我不断收到错误。

/var/lib/gems/1.8/gems/bundler-1.1.5/lib/bundler/rubygems_integration.rb:147:in `gem': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) 

I am trying to run "rails server webrick -p 80 -e production" 我正在尝试运行“rails server webrick -p 80 -e production”

production:
  adapter: postgresql
  encoding: unicode
  database: imentor
  pool: 5
  username: postgres
  password: 
  host: localhost
  port: 5432

My problem was that I didn't actually know where to edit the gemfile ( (looked at the wrong gem file originally) 我的问题是我实际上并不知道在哪里编辑gemfile((最初查看错误的gem文件)

adding "gem 'pg'" to the Gemfile fixed it. 将“gem'pg'”添加到Gemfile中修复它。 Thanks to 'mu is too short' 感谢'亩太短'

My problem was that I didn't actually know where to edit the gemfile (looked at the wrong gem file originally) 我的问题是我实际上并不知道在哪里编辑gemfile(最初查看错误的gem文件)

adding "gem 'pg'" to the Gemfile fixed it. 将“gem'pg'”添加到Gemfile中修复它。 Thanks to 'mu is too short' 感谢'亩太短'

在ubuntu上,我就是这么做的

apt-get install libpgsql-ruby

I ran into a problem like this a few weeks back. 几个星期前我遇到了这样的问题。 I think you should try adding this code to the boot.rb file at first. 我想你应该首先尝试将此代码添加到boot.rb文件中。

require 'yaml'
YAML::ENGINE.yamler = 'syck'

You should also try addding this to the grmfile and run a bundle install right after 您还应该尝试将此添加到grmfile并立即运行bundle install

gem 'pg'

If it helps also this is a sample of my database.yml file. 如果它也有帮助,这是我的database.yml文件的示例。 Hope it works! 希望它有效!

production:
  adapter: postgresql
  encoding: unicode
  database: dezirus
  username: postgres
  password: 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM