# Config.after\_initialize doesn't seem to run

**URL:** <https://www.ruby-forum.com/t/config-after-initialize-doesnt-seem-to-run/144058>\
**Category:** Rails\
**Created:** [July 24, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/config-after-initialize-doesnt-seem-to-run/144058 "2008-07-24T23:35:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [July 24, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/config-after-initialize-doesnt-seem-to-run/144058/1 "2008-07-24T23:35:56Z")

</div>

At the end of config/development.rb I have:

config.after\_initialize do  
ExceptionNotifier.exception\_recipients = [‘removed\_email\_address@domain.invalid’]  
FOOBAR = ‘123’ # Just for testing  
end

Now, when I run script/console (or the web server) it seems that the  
after\_inialize block doesn’t run:

Loading development environment.

> > ExceptionNotifier.exception\_recipients  
> > =\> nil
> 
> > FOOBAR  
> > =\> NameError: uninitialized constant FOOBAR

I’m on Rails 1.2.5, BTW.

What am I missing?

Thanks,

Brian

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [July 24, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/config-after-initialize-doesnt-seem-to-run/144058/2 "2008-07-24T23:55:15Z")

</div>

Okay so the constant thing seems to be a namespace issue. The following  
works:

config.after\_initialize do  
Kernel.const\_set(‘FOOBAR’, ‘123’)  
end

> > FOOBAR  
> > =\> ‘123’

However,

config.after\_initialize do  
ExceptionNotifier.exception\_recipients = [‘removed\_email\_address@domain.invalid’]  
puts “Recipients are #{ExceptionNotifier.exception\_recipients}”  
end

When I run script\console, I see:

Loading development environment.  
Recipients are removed\_email\_address@domain.invalid

> > ExceptionNotifier.exception\_recipients  
> > =\> nil

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [July 24, 2008, 11:57pm UTC](https://www.ruby-forum.com/t/config-after-initialize-doesnt-seem-to-run/144058/3 "2008-07-24T23:57:29Z")

</div>

Ack. Problem was my fault. I had conflicting code in environment.rb.
