簡體   English   中英

修改后的config / environment / development.rb以能夠連接到電子郵件服務器。 重新啟動Rails服務器時,出現錯誤

[英]modified config/ environments/ development.rb to be able to connect to an email server. When I restart rails server I get an error

做我的第一個Rails開發時,修改了config / environment / development.rb以能夠連接到電子郵件服務器。 重新啟動Rails服務器時,出現以下錯誤消息:

“ ... Ruby / learn-rails / config / environments / development.rb:39:語法錯誤,意外'=',期望=>(SyntaxError)... default_url_options = {:host =>'localhost:3000'} ...”。

我沒有看到語法錯誤,有人看到我錯了嗎?

我添加到development.rb文件的代碼如下所示:

   config.action_mailer.smtp_settings = { 
   address: "smtp.gmail.com", 
   port: 587, 
   domain: Rails.application.secrets.domain_name, 
   authentication: "plain", 
   enable_starttls_auto: true, 
   user_name: Rails.application.secrets.email_provider_username, 
   password: Rails.application.secrets.email_provider_password 
   } 

#ActionMailer配置

  config.action_mailer.default_url_options = { :host = > 'localhost: 3000'}
  config.action_mailer.delivery_method = :smtp 
  config.action_mailer.raise_delivery_errors = true

您的問題是這一行:

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

您的hashrocket中有一個空格...請嘗試:

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

另外,將來,該堆棧跟蹤為您提供錯誤所在的確切行號:

 Ruby/learn-rails/config/environments/development.rb:39

這表明問題出在config/environments/development.rb第39行上。您可以在文本編輯器中精確地轉到該行以查找其抱怨的錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM