【问题标题】:Connection refused on Devise forgotten password, in RoR app deployment在 RoR 应用程序部署中,在设计忘记密码时连接被拒绝
【发布时间】:2015-02-25 05:13:41
【问题描述】:

我正在尝试在我的 RoR 应用程序中使用 devise gem。它工作正常,除了在生产模式下我无法收到忘记密码的电子邮件。该页面显示此错误:

Errno::ECONNREFUSED in Devise::PasswordsController#create
Connection refused - connect(2)

Rails.root: /app

Application Trace | Framework Trace | Full Trace
Request

Parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"S8rQE7SyT4+7gLvwIiFG+violKPAhzzKMZKUiH0xUSU=",
 "user"=>{"email"=>"myemail@whatever.com"},
 "commit"=>"Send me reset password instructions"}

我应该提一下:

  • 我已经在 heroku 上运行了 db 迁移,没有任何错误。
  • 在开发中运行良好(已发送电子邮件)
  • 我正在使用山魈
  • heroku 日志显示某种 heroku 路由器错误:
heroku[router]: at=info method=POST path="/users/password" host=myappname.herokuapp.com request_id
=7e327911-49cb-448a-aa33-13f4bda8c3f dyno=web.1 connect=2ms service=351ms status=500 bytes=1754

production.rb 中的邮件配置与 development.rb 中的相同:

config.action_mailer.delivery_method = :smtp
# change to true to allow email to be sent during development
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"

config.action_mailer.smtp_settings = {
  address: ENV["MAIL_ADDRESS"],
  port: 587,
  user_name: ENV["MAIL_USERNAME"],
  password: ENV["MAIL_PASSWORD"]
}

另外,在 production.rb 我有:

config.action_mailer.default_url_options = { :host => 'myappname.herokuapp.com'}

development.rb 我有:

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

database.yml 文件如下所示:

default: &default
  adapter: postgresql
  user: <%= ENV['DB_USER'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  pool: 5
  timeout: 5000
  port: 5432

development:
  <<: *default
  database: <%= ENV['DB_NAME_DEV'] %>

test:
  <<: *default
  database: <%= ENV['DB_NAME_TEST'] %>

production:
  <<: *default
  database: <%= ENV['DB_NAME_PROD'] %>

【问题讨论】:

    标签: ruby-on-rails heroku devise mandrill


    【解决方案1】:

    终于明白了。

    我使用 Figaro gem 来存储我的环境数据,但即使这些密钥在开发中可用,也必须让 heroku 可见。只有在这个额外的步骤之后,它们才能在生产中使用:

    $ figaro heroku:set
    

    或者,您可以使用以下方法设置这些变量:

    $ heroku config:add <key>=<value>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-12
      • 1970-01-01
      • 2021-06-27
      • 1970-01-01
      • 2018-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多