无法让 Postgresql 数据库与 Ruby on Rails 3 一起使用

发布于 2024-10-26 05:06:39 字数 2328 浏览 0 评论 0原文

环境

  • Windows 7 64位
  • Ruby 1.8.7
  • Rails 3.0.0
  • pg AdminIII
  • PostgreSQL 9.0.3
  • Cygwin

Gemfile

http://i54.tinypic.com/27yzxv4.png

数据库配置

http://i53.tinypic.com/288b7ma.png

我采取的步骤

  • 我尝试添加“gem 'postgres-pr', :require => 'pg'" 到 gemfile
  • 尝试安装 postgres gem 的多个变体,
    • postgres-pr
    • pg
    • ruby-pg

当尝试运行 rake db:migrate 时,我不断收到此错误

rake aborted!
no such file to load -- pg
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
/home/Other/rails_projects/test_project/config/application.rb:7
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
/home/Other/rails_projects/test_project/Rakefile:4
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

已经这样做了几天,确实需要一些帮助。提前致谢!

Environment

  • Windows 7 64 bit
  • Ruby 1.8.7
  • Rails 3.0.0
  • pg AdminIII
  • PostgreSQL 9.0.3
  • Cygwin

Gemfile

http://i54.tinypic.com/27yzxv4.png

Database Config

http://i53.tinypic.com/288b7ma.png

Steps I have taken

  • I tried addding "gem 'postgres-pr', :require => 'pg'" to the gemfile
  • Have tried installing multiple variations of the postgres gem,
    • postgres-pr
    • pg
    • ruby-pg

I continually get this error when trying to run rake db:migrate

rake aborted!
no such file to load -- pg
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
/home/Other/rails_projects/test_project/config/application.rb:7
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
/home/Other/rails_projects/test_project/Rakefile:4
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

Been at this for a couple days, really need some help. Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笙痞 2024-11-02 05:06:39

您需要为 gem 指定正确的平台。在我的 Gemfile 中,我有:(

group :development, :test do
  gem 'pg', :platforms => :mingw
end

该组之所以存在,是因为我部署到 Unix 机器上,其中平台明显不同)。我似乎记得我还需要 DevKit 才能正常工作。

You need to specify the correct platform for the gem. In my Gemfile, I have:

group :development, :test do
  gem 'pg', :platforms => :mingw
end

(The group is there because I deploy to a Unix box, where the platform is obviously different). I seem to remember that I also needed the DevKit for this to work.

不及他 2024-11-02 05:06:39

你需要安装 pg 并添加到你的 Gemfile 中

gem 'pg'

You need to install pg and add to your Gemfile

gem 'pg'
萝莉病 2024-11-02 05:06:39

您可能需要将 Rails 版本升级到 3.0.1 - 3.0.9,并运行 gem install pg。然后为了更好地重新运行bundle install

You may need to upgrade your version of Rails to 3.0.1 - 3.0.9 and also run gem install pg. Then just for good measure re-run bundle install.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文