ruby on rails教程ch 10可以获得邮件但链接错误也Bitbucket无法添加代码

我已经部分解决了这个问题:我可以获得确认和重置密码的链接。 问题是这些链接指向错误的应用程序,我需要手动调整应用程序的名称,以获得正确的重定向。 Heroku代表说那些错误的地址与代码有关….

1.在Michael Harti ruby​​ on rails教程中我可以找到并更改代码吗?

我使用Cloud 9和Bitbucket作为存储库。 我已经在Bitbucket上创建了新应用程序克隆我现有的应用程序,从Bitbucket到Cloud,并希望将其推送到Bitbucket以进行一些更改。 但Bitbucket不允许我说有现有的应用程序。 克隆可能在这种情况下不起作用。

2.如何创建与Bitbucket中现有完全相同的应用程序,但在Cloud9上使用不同的名称并将其推送到具有不同名称的Bitbucket?

谢谢。

//config/environments/production.rb

config.action_mailer.raise_delivery_errors = true

config.action_mailer.delivery_method =:smtp

host =’tatyanaa.herokuapp.com’

config.action_mailer.default_url_options = {host:host}

ActionMailer :: Base.smtp_settings = {

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

}

如果您在控制台中看到该输出,则表示您的电子邮件实际已发送。

通过“发送”我的意思是Rails处于开发模式,而不是真正发送电子邮件(所以你不需要设置任何东西),它将它输出到控制台,就像你可以看到那里。

可以通过设置在development.rb更改此配置

 config.action_mailer.delivery_method = :stmp config.action_mailer.perform_deliveries = true 

然后,您需要正确配置smtp设置,查看Action Mailer配置指南以获取更多详细信息,应该是这样的:

 config.action_mailer.delivery_method = :stmp config.action_mailer.perform_deliveries = true config.action_mailer.smtp_settings = { address: "foo.bar.com", user_name: "someone", password: "apassword" } 

但是,我强烈建议您保留默认配置,让它登录控制台,而不是发送真实的电子邮件。

你是否正确编写了production.rb的代码? 这是我的(我也遵循相同的教程,它工作):

 (production.rb) .... config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp host = 'my_heroku_app_name.herokuapp.com' config.action_mailer.default_url_options = { host: host } ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], :domain => 'heroku.com', :enable_starttls_auto => true } .... 

你是否也正确配置sendgrid作为heroku上的插件?

 (terminal window) heroku addons:create sendgrid:starter 

如果您遇到困难并且真的不知道如何继续,我建议您从一开始就重新开始教程。 当(我假设)你还没有完成整个教程本身时,再次通过相同的过程似乎效率低下。 相信我,我也有同样的情况,我“想”我在应用程序因某种原因停止工作之前正确地遵循了教程的每一步,当我从头开始重新启动它并再次执行步骤时,这一次有一个更放松的头脑,代码工作得很完美:)而且我已经完成相同的教程“4次”才能最终“得到它”。 如果你再次重复相同的过程,我认为这对你有好处,因为它有助于巩固你的知识并解决问题。