ali*_*lik 26 ruby-on-rails actionmailer environment-variables ruby-on-rails-3.1
有时当我开发时,我没有互联网连接.这会导致我的应用程序发送电子邮件时出错:
getaddrinfo: nodename nor servname provided, or not known
Run Code Online (Sandbox Code Playgroud)
有没有一种简单快捷的方法,我可以更改配置值,使ActionMailer不尝试实际发送电子邮件,而不是抛出错误?也许是开发环境的一些东西.或者其他一些方法,我可以避免错误被抛出,我的代码传递到我称之为actionmailer的地方?
我正在使用Rails 3.1
Wiz*_*Ogz 57
通常的做法就是让Rails忽略邮件错误.在您的config/environments/development.rb
文件中添加,取消注释或修改:
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
Run Code Online (Sandbox Code Playgroud)
你也可以这样设置:
config.action_mailer.perform_deliveries = false
Run Code Online (Sandbox Code Playgroud)
请参阅此处的文档http://edgeguides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
您还可以将交付方式设置为:test,但我还没有尝试过
config.action_mailer.delivery_method = :test
Run Code Online (Sandbox Code Playgroud)
dhu*_*han 14
如果要在初始化rails应用程序后(在创建示例数据时,在迁移期间等)禁用邮件传递:
ActionMailer::Base.perform_deliveries = false
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14278 次 |
最近记录: |