Here is my model:
class User
def join(race)
#blah blah blah ....
UserMailer.delay.join_race(self, race) #I'm stuck here
end
end
And my UserMailer like this
class UserMailer
def join_race(user, race)
#Another blah blah blah, nothing important here
mail(:to => user.email)
end
end
Now, whenever I call user.join(race)
, it shows the error like this:
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'
...
If I convert it to normal function (without the .delay
in front of join_race
), it works.
I found similar issues but they are all about not calling .all
method after using where
. I suspect that the self
could be the problem but I don't know how to make it work. If any of you have any clue, please share with me.