# App Setting, Where To Put: environment.rb, initializer.rb, lib..?

**URL:** <https://www.ruby-forum.com/t/app-setting-where-to-put-environment-rb-initializer-rb-lib/175959>\
**Category:** Rails\
**Created:** [September 23, 2009, 4:22am UTC](https://www.ruby-forum.com/t/app-setting-where-to-put-environment-rb-initializer-rb-lib/175959 "2009-09-23T04:22:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaggotChild](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@MaggotChild](https://www.ruby-forum.com/u/MaggotChild)\
**Post date:** [September 23, 2009, 4:22am UTC](https://www.ruby-forum.com/t/app-setting-where-to-put-environment-rb-initializer-rb-lib/175959/1 "2009-09-23T04:22:27Z")

</div>

I have a path that my model (Audio) uses to r/w files. This path  
differs between production, test, and dev.

Audio includes a module that overrides some ActiveRecord methods.  
This module is contained in config/initializers.

I’d like to set the Audio directory based on my environment, but using  
the given environment files fail because the module included by Audio  
hasn’t been loaded. Of course I could just require it, but this made  
me think that maybe the initilaizers directory isn’t the right place  
to put my AR overrides, and the environment file isn’t the right place  
to put my non-Rails related environment settings. Is this the case?

It seems as though I should set the directory in it’s own initializer  
based on RAILS\_ENV… but Rails is already doing this for me with the  
given environment files

---

<div class="post-metadata">

**Author:** ![MaggotChild](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@MaggotChild](https://www.ruby-forum.com/u/MaggotChild)\
**Post date:** [September 23, 2009, 5:19am UTC](https://www.ruby-forum.com/t/app-setting-where-to-put-environment-rb-initializer-rb-lib/175959/2 "2009-09-23T05:19:51Z")

</div>

I think the environment files are where you should set the different  
directories. I do think that the AR overrides should go into /lib…

If you want to change when something loads in the environments files  
use  
config.after\_initialize do  
…  
end

Here is an old but good article that talks about these issues and  
solutions  
[http://toolmantim.com/articles/environments\_and\_the\_rails\_initialisation\_process](http://toolmantim.com/articles/environments_and_the_rails_initialisation_process)

---

<div class="post-metadata">

**Author:** ![MaggotChild](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@MaggotChild](https://www.ruby-forum.com/u/MaggotChild)\
**Post date:** [September 23, 2009, 5:34am UTC](https://www.ruby-forum.com/t/app-setting-where-to-put-environment-rb-initializer-rb-lib/175959/3 "2009-09-23T05:34:29Z")

</div>

Thanks!
