0

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(body) .... 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

0

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks but then in my rspec I have: xxxx = :: xJob::find_it(stuff) and if I remove the self. then that fails. So what do I do?
RSPEC then fails with NoMethodError: undefined method
then just use, goodstuff = xJob.find_it(stuff) , instead of just "goodstuff = find_it(stuff)"
@Rishav, thanks I've tried that with the following in RSPEC: goodstuff = :: xJob. find_it(stuff) but that errors with NoMethodError: undefined method `find_it' for xJob:Class
I should add that find_it is inside a lib, that I use with delayed job, that looks like this: class xJob < Struct.new(:xxxx_id)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.