Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 延迟作业和电子邮件的语法问题_Ruby On Rails_Ruby_Actionmailer_Delayed Job - Fatal编程技术网

Ruby on rails 延迟作业和电子邮件的语法问题

Ruby on rails 延迟作业和电子邮件的语法问题,ruby-on-rails,ruby,actionmailer,delayed-job,Ruby On Rails,Ruby,Actionmailer,Delayed Job,我得到了一个漂亮的错误: failed with NoMethodError: You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[] - 3 failed attempts 我的控制器: CardSignup.all.each do |user|

我得到了一个漂亮的错误:

failed with NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[] - 3 failed attempts
我的控制器:

CardSignup.all.each do |user|
  Delayed::Job.enqueue MassEmail.new(user, params[:subject], params[:editor1])
end
mass\u email.rb

class MassEmail < Struct.new(:user, :subject, :message)
  def perform
    Notifier.deliver_email_blast(user, subject, message)
  end
end
class-MassEmail
\u form.html.haml

- form_tag admin_email_blast_path do
  Subject
  %br
  = text_field_tag 'subject'
  %br
  Body
  %br
  = text_area_tag 'message', '', :name => 'editor1'
  %br
  = submit_tag 'Send Email', :class => 'button'

  :plain
    <script type="text/javascript">
    CKEDITOR.replace( 'editor1' );
    </script>
-表单\u标签管理\u电子邮件\u爆炸\u路径执行
主题
%溴
=文本\字段\标记“主题”
%溴
身体
%溴
=文本\区域\标记'message','',:name=>'editor1'
%溴
=submit_标记‘发送电子邮件’,:class=>‘按钮’
:普通
CKEDITOR.replace('editor1');
问题是因为我没有通过正确的测试。。我该怎么做

注意:在我使用params[:subject]和params[:editor1]实现延迟_作业之前,它工作得非常好,因此我必须以某种方式保留它们

我在没有延迟工作的情况下尝试了这个,MasseEmail.new甚至没有在我的日志中留下回溯

我也在我的控制台上试过了,它冻结了


mass_email.rb或调用
def perform

这肯定是错误的,您给了两个参数相同的名称:

class MassEmail < Struct.new(:user, :params, :params)
class-MassEmail
方法现在如何执行您所引用的参数

你可以试试这样的

class MassEmail < Struct.new(:user, :subject, :editor1)
  def perform
    Notifier.deliver_email_blast(user, subject, editor1)
  end
end
class-MassEmail
感谢JigFox让我把参数写对了

我不完全确定为什么会这样,但我将循环移到了MassEmail.new函数中

Delayed::Job.enqueue MassEmail.new(params[:subject], params[:editor1])

class MassEmail < Struct.new(:subject, :editor1)
  def perform
    CardSignup.all.each do |user|
      Notifier.deliver_email_blast(user, subject, editor1)
    end
  end
end
Delayed::Job.enqueue MassEmail.new(参数[:subject],参数[:editor1])
类MassEmail
如果知道
NoMethodError
是在哪里产生的,那就太好了。我怎么找到它呢?这就是它的前兆2010-09-14T11:57:18-0400:[工人(延迟的工作主机:Daniel-Levines-iMac-3.local pid:754)]获得了MasseEmail的锁定2010-09-14T11:57:18-0400:[工作]延迟的工作主机:Daniel-Levines-iMac-3.local pid:754抱歉,但这没有帮助。通常情况下,您会得到一个完整的回溯跟踪,靠近错误消息一定是这样的:
some_path/some_file.rb:213
.Yah..即使我从延迟的作业中取出它,它也不会报告错误。疯狂,对吧?至少在语法上有了进步。但它仍然返回相同的错误。我会提供更好的跟踪,但它无法通过延迟的工作。我认为这是错误的,因为我在我的群发邮件中从我的表格中呼叫的VAR。new无法通过?