- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用collectiveidea的delay_job在Rails 3应用程序中发送邮件。如果我尝试定期发送邮件 (.deliver) 它工作正常,但是一旦我切换到延迟工作,事情就会崩溃。
我在 delay_job mysql 表中得到的标准错误是:
{undefined method `name' for nil:NilClass...
{A sender (Return-Path, Sender or From) required to send a message
def sendmail
@contact = Contact.new(params[:contact])
if @contact.save
ContactMailer.delay.contact_mail(@contact)
flash[:notice] = 'Your message has been successfully sent'
redirect_to root_path
else
render :action => 'index'
end
end
class ContactMailer < ActionMailer::Base
default :from => "my@email.address"
def contact_mail(contact)
@contact = contact
mail(:to => 'my@email.address', :subject => 'Contact Form Query', :from => 'my@email.address', :content_type => 'text/plain')
end
handle_asynchronously :contact_mail, :run_at => Proc.new { 2.seconds.from_now }
end
You have received a new query:
-----------------------------------
<%= @contact.name %>
<%= @contact.business %>
<%= @contact.phone %>
-----------------------
<%= @contact.message %>
-----------------------
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.max_run_time = 5.weeks
{undefined method `name' for nil:NilClass
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/whiny_nil.rb:48:in `method_missing'
/Users/john/Websites/Rails/InDevelopment/connectted/app/views/contact_mailer/contact_mail.html.erb:4:in `_app_views_contact_mailer_contact_mail_html_erb___3386534441642202773_2166008980__4301703149293725172'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/template.rb:135:in `block in render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications.rb:54:in `instrument'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/template.rb:127:in `render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/render/rendering.rb:59:in `block in _render_template'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications.rb:52:in `block in instrument'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications.rb:52:in `instrument'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/render/rendering.rb:56:in `_render_template'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/render/rendering.rb:26:in `render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:114:in `_render_template'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:108:in `render_to_body'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:101:in `render_to_string'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:92:in `render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/deprecated_api.rb:111:in `render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:210:in `block in create_parts'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:208:in `each'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:208:in `create_parts'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/deprecated_api.rb:143:in `create_parts'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:77:in `process'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:446:in `process'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:441:in `initialize'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `new'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `method_missing'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/performable_mailer.rb:6:in `perform'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/backend/base.rb:83:in `invoke_job'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:119:in `block (2 levels) in run'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed
/worker.rb:119:in `block in run'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:118:in `run'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:176:in `reserve_and_run_one_job'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:103:in `block in work_off'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:102:in `times'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:102:in `work_off'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:77:in `block (2 levels) in start'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:76:in `block in start'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:73:in `loop'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:73:in `start'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:100:in `run'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:79:in `block in run_process'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `call'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `block in start_proc'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call_as_daemon'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:254:in `start_proc'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:294:in `start'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/controller.rb:70:in `run'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons.rb:193:in `block in run_proc'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `call'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `catch_exceptions'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons.rb:192:in `run_proc'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:78:in `run_process'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:72:in `block in daemonize'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:70:in `times'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:70:in `daemonize'
script/delayed_job:5:in `<main>' |
最佳答案
问题在于邮件程序中的代码采用对象而不是对象 ID:
def contact_mail(contact)
@contact = contact
mail(:to => 'my@email.address', :subject => 'Contact Form Query', :from => 'my@email.address', :content_type => 'text/plain')
end
def contact_mail(contact_id)
@contact = Contact.find(contact_id)
mail(:to => 'my@email.address', :subject => 'Contact Form Query', :from => 'my@email.address', :content_type => 'text/plain')
end
关于ruby-on-rails - Rails : Absolutely stumped with delayed_job. 没有在任何地方接收参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4337879/
我正在使用 Gunicorn 为 Django 应用程序提供服务,它工作正常,直到我将其超时时间从 30 秒更改为 900000 秒,我不得不这样做,因为我有一个用例需要上传和处理一个巨大的文件(过程
我有一个带有非常基本的管道的Jenkinsfile,它可以旋转docker容器: pipeline { agent { dockerfile { args '-u root' } } stag
在学习 MEAN 堆栈的过程中,我遇到了一个问题。每当我尝试使用 Passport 验证方法时,它都不会返回任何响应。我总是收到“localhost没有发送任何数据。ERR_EMPTY_RESPONS
在当今的大多数企业堆栈中,数据库是我们存储所有秘密的地方。它是安全屋,是待命室,也是用于存储可能非常私密或极具价值的物品的集散地。对于依赖它的数据库管理员、程序员和DevOps团队来说,保护它免受所
是否可以创建像图片上那样的边框?只需使用 css 边框属性。最终结果将是没 Angular 盒子。我不想添加额外的 html 元素。我只想为每个 li 元素添加 css 边框信息。 假设这是一个 ul
我是一名优秀的程序员,十分优秀!