【问题标题】:when running 'rake db:setup' getting deprecation warning运行“rake db:setup”时收到弃用警告
【发布时间】:2020-05-17 22:51:33
【问题描述】:

希望有人可以在这里帮助我: 我有 * 将我应用程序中的数据库从 sqlit3 更改为 postgresql, * 将 gemfile 替换为 gem 'pg', * 更新database.yml

所有这些,都是为了能够部署到heroku。

当我跑步时

rake db:setup

我收到以下错误:

DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
Change:
  >> Coffee::Rails::TemplateHandler.call(template)
To:
  >> Coffee::Rails::TemplateHandler.call(template, source)
could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Couldn't create 'school-grades-project' database. Please check your configuration.
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

我读到 jbuilder 应该注意这个问题,所以我升级了 jbuilder,但问题仍然存在。

希望能得到一些帮助。 谢谢,

【问题讨论】:

  • 将coffee-rails gem 升级到更高版本(5.0.0)时,第一个警告被消除了。但是还是有连接不上服务器的问题
  • 您的 postgresql 实例没有监听 5432。您确定它正在运行吗?
  • 现在,我收到此错误消息:PG::ConnectionBad: could not connect to server: No such file or directory 服务器是否在本地运行并接受 Unix 域套接字上的连接“/var/pgsql_socket /.s.PGSQL.5432"?
  • 错误信息和Josh Brody's comment中的问题的答案是什么?
  • 是的,postgresql 正在运行...

标签: ruby-on-rails ruby rubygems


【解决方案1】:

这有点难以诊断,因为您没有指定正在使用的 Rails 版本或database.yml 文件的内容。但假设它是支持数据库 URL 的最新 Rails 版本,它应该按照 Getting started guide for Rails 中的描述工作。

# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
#   DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
#   production:
#     url: <%= ENV['DATABASE_URL'] %>
#

您是否取消了production 设置的注释?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 1970-01-01
    • 2021-02-16
    • 1970-01-01
    相关资源
    最近更新 更多