librelist archives

« back to archive

"uninitialized constant" error

"uninitialized constant" error

From:
Mason Jones
Date:
2010-03-16 @ 23:35
Hello, after hitting an error with getting my first Resque worker set
up, I was looking at the list archives and saw this:

> Apparently your worker doesn't know any thing about your classes. make
> sure to load your classes in your rake task.

in response to a question the other day about getting the
"uninitialized constant MyClass" error. This is due to my relative
newness with Rails I suppose, but I'm not sure precisely what's meant
there by "load your classes". I'm doing the rake task straight from
the Resque docs:

$ QUEUE=my_queue rake resque:work

with my worker class in the Rails /lib directory so it should be
found, and I assumed that the worker would be run in the Rails
environment and thus the class would be found following the
Resque.enqueue(MyClass, parms) call. Apparently that's an incorrect
assumption?

Sorry for the perhaps obvious question -- thanks very much.

Re: [resque] "uninitialized constant" error

From:
Chris Wanstrath
Date:
2010-03-17 @ 02:12
No, the worker is not run in the Rails environment - as explained in the README.

$ QUEUE=my_queue rake environment resque:work

On Tuesday, March 16, 2010, Mason Jones <masonoise@gmail.com> wrote:
> Hello, after hitting an error with getting my first Resque worker set
> up, I was looking at the list archives and saw this:
>
>> Apparently your worker doesn't know any thing about your classes. make
>> sure to load your classes in your rake task.
>
> in response to a question the other day about getting the
> "uninitialized constant MyClass" error. This is due to my relative
> newness with Rails I suppose, but I'm not sure precisely what's meant
> there by "load your classes". I'm doing the rake task straight from
> the Resque docs:
>
> $ QUEUE=my_queue rake resque:work
>
> with my worker class in the Rails /lib directory so it should be
> found, and I assumed that the worker would be run in the Rails
> environment and thus the class would be found following the
> Resque.enqueue(MyClass, parms) call. Apparently that's an incorrect
> assumption?
>
> Sorry for the perhaps obvious question -- thanks very much.
>

-- 
Chris Wanstrath
http://github.com/defunkt

Re: [resque] "uninitialized constant" error

From:
Mason Jones
Date:
2010-03-17 @ 03:30
Oh man, I see, thanks very much. I read through that bit in the README
but my lack of familiarity with how rake fits into the picture made me
miss its significance. Works beautifully now.

Thanks again.


On Tue, Mar 16, 2010 at 7:12 PM, Chris Wanstrath <chris@ozmm.org> wrote:
> No, the worker is not run in the Rails environment - as explained in the README.
>
> $ QUEUE=my_queue rake environment resque:work
>
> On Tuesday, March 16, 2010, Mason Jones <masonoise@gmail.com> wrote:
>> Hello, after hitting an error with getting my first Resque worker set
>> up, I was looking at the list archives and saw this:
>>
>>> Apparently your worker doesn't know any thing about your classes. make
>>> sure to load your classes in your rake task.
>>
>> in response to a question the other day about getting the
>> "uninitialized constant MyClass" error. This is due to my relative
>> newness with Rails I suppose, but I'm not sure precisely what's meant
>> there by "load your classes". I'm doing the rake task straight from
>> the Resque docs:
>>
>> $ QUEUE=my_queue rake resque:work
>>
>> with my worker class in the Rails /lib directory so it should be
>> found, and I assumed that the worker would be run in the Rails
>> environment and thus the class would be found following the
>> Resque.enqueue(MyClass, parms) call. Apparently that's an incorrect
>> assumption?
>>
>> Sorry for the perhaps obvious question -- thanks very much.
>>
>
> --
> Chris Wanstrath
> http://github.com/defunkt
>

Re: [resque] "uninitialized constant" error

From:
Chris Wanstrath
Date:
2010-03-17 @ 15:11
Many people run into this. The task should probably try to load the
environment by default.

On Tuesday, March 16, 2010, Mason Jones <masonoise@gmail.com> wrote:
> Oh man, I see, thanks very much. I read through that bit in the README
> but my lack of familiarity with how rake fits into the picture made me
> miss its significance. Works beautifully now.
>
> Thanks again.
>
>
> On Tue, Mar 16, 2010 at 7:12 PM, Chris Wanstrath <chris@ozmm.org> wrote:
>> No, the worker is not run in the Rails environment - as explained in 
the README.
>>
>> $ QUEUE=my_queue rake environment resque:work
>>
>> On Tuesday, March 16, 2010, Mason Jones <masonoise@gmail.com> wrote:
>>> Hello, after hitting an error with getting my first Resque worker set
>>> up, I was looking at the list archives and saw this:
>>>
>>>> Apparently your worker doesn't know any thing about your classes. make
>>>> sure to load your classes in your rake task.
>>>
>>> in response to a question the other day about getting the
>>> "uninitialized constant MyClass" error. This is due to my relative
>>> newness with Rails I suppose, but I'm not sure precisely what's meant
>>> there by "load your classes". I'm doing the rake task straight from
>>> the Resque docs:
>>>
>>> $ QUEUE=my_queue rake resque:work
>>>
>>> with my worker class in the Rails /lib directory so it should be
>>> found, and I assumed that the worker would be run in the Rails
>>> environment and thus the class would be found following the
>>> Resque.enqueue(MyClass, parms) call. Apparently that's an incorrect
>>> assumption?
>>>
>>> Sorry for the perhaps obvious question -- thanks very much.
>>>
>>
>> --
>> Chris Wanstrath
>> http://github.com/defunkt
>>
>

-- 
Chris Wanstrath
http://github.com/defunkt