# Observer doesn't work properly... in development?

**URL:** <https://www.ruby-forum.com/t/observer-doesnt-work-properly-in-development/149100>\
**Category:** Rails\
**Created:** [September 20, 2008, 12:22pm UTC](https://www.ruby-forum.com/t/observer-doesnt-work-properly-in-development/149100 "2008-09-20T12:22:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [September 20, 2008, 12:22pm UTC](https://www.ruby-forum.com/t/observer-doesnt-work-properly-in-development/149100/1 "2008-09-20T12:22:57Z")

</div>

Hey all!

Ok, weird problem with observer. Most of the time, the after\_create  
of UserObserver isn’t called. It’s like it just skips it altogether.  
However, when I stop the server, add a line “debugger” in the  
after\_create block, and restart the server with the debugger option,  
and try creating a user again, the callback is executed! If I remove  
the debugger in the block and restart the server, it’s back to  
ignoring it. Another thing, if I leave the debugger line in the  
after\_create block, but restart the server _without_ the debugger  
option, when I create a user I see in the logs:

\*\*\*\*\* Debugger requested, but was not available: Start server with  
–debugger to enable \*\*\*\*\*

So, it tells me that it somewhat enters the after\_create method but  
doesn’t execute my BackgroundRB Middleman job?

Anyone else see this behavior before?

I asked around in #rubyonrails in freenode and someone mentioned that  
it might be because I’m running it in development mode. He vaguely  
remembers a way to run observers properly. I want it to run in  
development too, of course. Funny thing is, as far as I can tell, my  
after\_save methods are always called.

I hope you guys can help.

## Thanks!

Ramon T.

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [September 20, 2008, 12:54pm UTC](https://www.ruby-forum.com/t/observer-doesnt-work-properly-in-development/149100/2 "2008-09-20T12:54:41Z")

</div>

I transferred the callback to the model, and it seems that it’s the  
same problem. I think the problem lies in BackgroundRB then, not  
Rails or the observer. Thanks for reading my previous mail though!  
Off to the backgroundrb mailing list.

On Sat, Sep 20, 2008 at 6:22 PM, Ramon Miguel M. Tayag  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> option, when I create a user I see in the logs:  
> it might be because I’m running it in development mode. He vaguely  
> remembers a way to run observers properly. I want it to run in  
> development too, of course. Funny thing is, as far as I can tell, my  
> after\_save methods are always called.
> 
> I hope you guys can help.
> 
> ## Thanks!
> 
> Ramon T.

–  
Ramon T.

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [September 21, 2008, 12:36pm UTC](https://www.ruby-forum.com/t/observer-doesnt-work-properly-in-development/149100/3 "2008-09-21T12:36:57Z")

</div>

Thanks conrad this’ll be useful 🙂

On Sat, Sep 20, 2008 at 7:34 PM, Conrad T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > Hey all!
> > > 
> > > remembers a way to run observers properly. I want it to run in  
> > > Hi Ramon, I would recommend creating an environment file called staging.rb  
> > > development.rb to work like the production.rb.  
> > > Good luck,  
> > > -Conard
> 
> >

–  
Ramon T.

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [September 20, 2008, 1:35pm UTC](https://www.ruby-forum.com/t/observer-doesnt-work-properly-in-development/149100/4 "2008-09-20T13:35:04Z")

</div>

On Sat, Sep 20, 2008 at 3:53 AM, Ramon Miguel M. Tayag \<  
removed\_email\_address@domain.invalid\> wrote:

> > Ok, weird problem with observer. Most of the time, the after\_create  
> > –debugger to enable \*\*\*\*\*  
> > after\_save methods are always called.
> > 
> > I hope you guys can help.
> > 
> > ## Thanks!
> > 
> > Ramon T.

Hi Ramon, I would recommend creating an environment file called  
staging.rb  
by doing the following:

cd \<RAILS\_APP\_ROOT\>/config/environments

cp production.rd staging.rb

Next, you’ll need to create staging section within your database.yml  
located  
in cd \<RAILS\_APP\_ROOT\>/config

cd \<RAILS\_APP\_ROOT\>

script/server staging

In short, your staging environment will be used to mimic the actual  
production environment without hitting the  
production server. You don’t really want to start changing the  
development.rb to work like the production.rb.

Good luck,

-Conard
