【问题标题】:EOF error in Rails utilizing the devise gem使用设计 gem 的 Rails 中的 EOF 错误
【发布时间】:2020-06-18 12:59:52
【问题描述】:

我最近设置了用于身份验证的设计 gem,除了忘记密码功能之外,一切都运行良好。我的 smtp 目前指向一个 yahoo 电子邮件地址。然而,我收到文件扩展名错误的 EOF 结尾。在开发中,它可以很好地传递消息,但在生产中无济于事。此外,我使用 Heroku Config:set 初始化了用户名和密码的 ENV 变量。另外,我尝试了端口 587。任何帮助将不胜感激!我对 Rails 相当陌生,并搜索了类似的日志问题,但与此问题的相似性差异最大。谢谢!

config.action_mailer.perform_caching = false

  config.action_mailer.default_url_options = {:host => 'https:app.herokuapp.com' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true




  ActionMailer::Base.smtp_settings = {
    :user_name => ENV['example@yahoo.com'],
    :password => ENV['examplepass'],
    :domain => 'https://example.herokuapp.com/',
    :address => 'smtp.mail.yahoo.com',
    :port =>465,
    :authentication => "plain",
    :enable_starttls_auto => true,

  }

【问题讨论】:

    标签: ruby-on-rails ruby devise


    【解决方案1】:

    我的第一个想法:

    我认为您的文件有不可见的字符,请尝试清理您的文件。 https://alvinalexander.com/blog/post/linux-unix/how-remove-non-printable-ascii-characters-file-unix

    删除文件并创建一个新文件并重写配置,避免复制粘贴。如果您在没有格式的情况下复制粘贴到注释块中,可能会起作用,然后将其复制回您的文件中。

    还可以阅读更多What is an EOFError in Ruby file I/O? https://airbrake.io/blog/ruby-exception-handling/eof-error

    继续搜索我找到了这个

    EOFError in Devise::PasswordsController#create

    Devise mailer EOF error 用户对此发表评论

    啊,经典。我的 config/secrets.yml 没有在 git 中(自然地)被跟踪并且 > 看起来它被覆盖并且在某些时候丢失了电子邮件 >provider smtp/username/password 的那些条目。谢谢

    另一个Rails EOFError (end of file reached) when saving a devise user

    【讨论】:

      【解决方案2】:

      解决我的问题有两个方面。我没有正确设置和初始化 heroku 配置变量。我的 .gitignore 文件也没有排除项以防止上传到存储库。总之,我添加了 figaro gem,bundle exec install figaro,它创建了存储实际用户/密码信息所需的 application.yml。 https://railsapps.github.io/rails-environment-variables.html ----> 在解释设置变量的选项时非常有用。

      
      
        :user_name => ENV['SENDGRID_USERNAME'],
        :password => ENV['SENDGRID_PASSWORD'],
        :domain => 'heroku.com',
        :address => 'smtp.sendgrid.net',
        :port =>587,
        :authentication => :plain,
        :enable_starttls_auto => true,
      
      

      同样在上面的代码中,我没有为 heroku.com 指定域,但我在 Heroku 上的应用程序域。对于 production.rb,您确实需要将默认 url 设置为您的应用程序名称。如果您在 production.rb 中保留默认 url “heroku.com”,则单击电子邮件链接时会出现 404 错误。

      config.action_mailer.default_url_options = {:host => 'https://exampleapp.herokuapp.com/' }
      

      感谢您的帮助!我也希望这对其他新的 Rails 开发人员有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-11-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-24
        • 1970-01-01
        相关资源
        最近更新 更多