I'm getting the following error:
#<NoMethodError: undefined method `find_it' for #<struct xJob xxxx_id=527>>
I have a controller, which creates a delayed_job as follows, at the end of the controller method:
xJob.new(@xxxx.id).perform
Then in /lib/xJob.rb:
class xJob < Struct.new(:xxxx_id)
include ActionView::Helpers
def perform
begin
.......
goodstuff = find_it(stuff)
.......
rescue Exception => e
.....
end
end
def self.find_it(b开发者_如何学Cody)
....
end
end
I needed to add the self to self.find_it otherwise it I couldn't test that method in rspec. But now it seems to be breaking outside of RSPEC.
Ideas? Thanks
Just remove the "self" from the find_it method declaration. Because its when you define it like that it becomes a class method of xJob, instead of a instance method.
精彩评论