我不知道如何在 windows8 上的 rails 上的 ruby 中安装 postgresql10.7。1

I can't figure how to install postgresql10.7 in ruby on rails on windows8.1

在 RubyRails 上阅读 Michael Hartl 的书时,我决定使用 postgresql 而不是书中使用的 sqlite3 版本(虽然,我无法获得 sqlite3 gem 安装在 Ruby 上 Rails 但我不太关心,因为我的重点是使用 pg) 这是我到目前为止采取的步骤

第一步:我下载了postgreSQL 10.7版本并安装了 Step2:将路径添加到路径环境 第 3 步:我将其添加到

Gemfile like this 'pg', '~>10.7'

第四步:运行

Rails bundle

我从控制台得到了什么

Could not find gem 'pg (= 10.7) x64-mingw32' in any of the gem sources listed in your Gemfile.

我的问题是如何在 windows

中的 Rails 上安装 Ruby 上的 pg 版本或任何其他版本

终于,我自己弄明白了,这就是我所做的 我这样注释掉sqlite3

gem install 'sqlite3'

替换为

gem install 'pg'

之后,我去

config folder

和select

database.yml

并将设置更改为这些

default: &default
  adapter: postgresql
  encoding: unicode
  host: localhost
  username: postgresql
  password: your password
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: db_dating

test:
  <<: *default
  database: db_dating_test

我创建的数据库名称叫

db_dating

所以记得将您的名称更改为您的数据库名称