Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.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,这是我的模型: class User def join(race) #blah blah blah .... UserMailer.delay.join_race(self, race) #I'm stuck here end end 我的用户邮箱是这样的 class UserMailer def join_race(user, race) #Another blah blah blah, nothing important here mail(:t

这是我的模型:

class User
  def join(race)
    #blah blah blah ....
    UserMailer.delay.join_race(self, race) #I'm stuck here
  end
end
我的用户邮箱是这样的

class UserMailer
  def join_race(user, race)
    #Another blah blah blah, nothing important here
    mail(:to => user.email)
  end
end
现在,每当我调用
user.join(race)
,它都会显示如下错误:

ArgumentError: wrong number of arguments (2 for 1)
from /home/xxx/.rvm/gems/ruby-1.9.3-p194/gems/arel-3.0.2/lib/arel/expressions.rb:3:in `count'
from /home/xxx/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:224:in `binary?'
from /home/xxx/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:233:in `visit_String'
from /home/xxx/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `accept'
from /home/xxx/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:292:in `block in visit_Hash'
from /home/xxx/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:290:in `each'
 ...
如果我将其转换为正常功能(在
join\u race
前面没有
.delay
),它就会工作


我发现了类似的问题,但都是关于在使用
where
后不调用
.all
方法。我怀疑
self
可能是问题所在,但我不知道如何让它工作。如果你们有任何线索,请与我分享。

中讨论了这个问题,包括提到邮寄和延迟工作,以及相关问题

包括以下解决方法:

module Arel
  module Nodes
    class SqlLiteral < String
      def encode_with(coder)
        coder['string'] = to_s
      end
      def init_with(coder)
        clear << coder['string']
      end
    end
  end
end
模块Arel
模块节点
类SqlLiteral清楚问题是因为我使用的是Rails 3.2.12。似乎这个问题只发生在这个版本的Rails中。因此,我将我的项目升级到Rails 3.2.13,一切正常。

请至少共享回溯中的下一行,以便我们可以看到哪些代码调用
count
方法并传递两个参数,而不是允许的1(或0)。您好,我更新了堆栈跟踪。但我个人认为堆栈跟踪中没有有用的信息。希望你能从他们那里得到一些东西。我尝试过这个解决方法,但没有成功。我将我的项目升级到Rails 3.2.13,它解决了这个问题。很高兴您能够让事情正常运行。我的回答对你有帮助吗?特别是,你看了我提供的第二个链接了吗?是的,我看了第二个链接,Rails版本让我考虑升级。谢谢我现在在Rails 3.2.19上,我看到了这个问题。