【问题标题】:Ruby-on-rails + Postgres: configuration issueRuby-on-rails + Postgres:配置问题
【发布时间】:2010-08-14 22:26:51
【问题描述】:

在 Windows 7 ruby​​ 1.8.6、rails 2.3.8、一些基本 gem(还有 ruby​​-postgres)和 Jetbrains 的 IDE Rubymine 中安装后,我遇到了一些麻烦。

因此,在使用 Rubymine(database.yml 中的默认 PostgresSQL 配置)创建了一个简单项目后,我在 localhost:3000 中运行它,但它似乎无法识别:

当我第一次在“关于你的应用程序的环境”中单击 Ruby on Rails 的主页时 它返回一个错误:“我们很抱歉,但出了点问题。”,即使我创建一个带有视图的简单控制器并打开正确的 URL,它也会出现同样的问题。

我不知道问题是关于数据库还是类似的东西,但我也想知道如何在database.yml中配置它。

默认值:

  adapter: postgresql
  encoding: unicode
  database: (name of the project)_(type: test, production or development)
  pool: 5
  username: (name of the project)
  password: (no password)

我做了什么:

  adapter: postgresql
  encoding: utf-8
  database: (name of database)_(type: test, production or development)
  pool: 5
  username: ruby
  password: (no password)
  host: localhost
  port: 3000

对吗?

【问题讨论】:

  • 你的日志文件说发生了什么?

标签: ruby-on-rails postgresql rubymine


【解决方案1】:

我对在 Windows 上运行 Rails 了解不多,但看看上面的 database.yml 文件,你不应该说port: 3000。这是运行 rails 应用程序的默认端口。您需要放置 PostgreSQL 正在运行的端口,通常是 5432。

【讨论】:

    【解决方案2】:

    假设您的项目名为 foo,并且您已在 postgres 中创建了正确的数据库,并且 postgres 正在侦听 localhost 上的默认端口

     development:
        adapter: postgresql
        encoding: utf-8
        database: foo_development 
        pool: 5
        user: ruby
    

    如前所述,端口 3000 是 rails 监听的地方,因此会导致问题。您还需要确保 pga_hba.conf 允许连接到数据库。

    【讨论】:

    • 感谢您的信息,我做了所有的事情,但我在 Rubymine 中找不到的唯一一件事是在哪里将端口 3000 更改为 5432,因为每次运行项目时它都会变为 3000。(我已经更改了 database.yml 端口)
    • 你不需要把端口改成5432,5432是postgresql服务器启动时默认监听的端口。端口 3000 是运行 ruby​​ on rails 开发服务器的默认端口。每个进程都需要自己的端口号,否则它将无法绑定并且无法运行。除非您有奇怪的配置,否则无需更改 postgresql 端口或 ruby​​ on rails 开发端口号。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-26
    • 1970-01-01
    • 1970-01-01
    • 2011-02-13
    • 2011-09-18
    • 1970-01-01
    • 2015-02-06
    相关资源
    最近更新 更多