# Environment.rb ruby path issue

**URL:** <https://www.ruby-forum.com/t/environment-rb-ruby-path-issue/125525>\
**Category:** Rails\
**Created:** [January 9, 2008, 10:51pm UTC](https://www.ruby-forum.com/t/environment-rb-ruby-path-issue/125525 "2008-01-09T22:51:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 9, 2008, 10:51pm UTC](https://www.ruby-forum.com/t/environment-rb-ruby-path-issue/125525/1 "2008-01-09T22:51:48Z")

</div>

I’m attempting to add a path to my rails app by adding the line :  
config.load\_paths += %W( #{RAILS\_ROOT}/new\_path )  
to my config/environments/development.rb file. For some reason rails  
doesn’t seem to be picking up the module located in this path, however  
when I add that same line to my config/environment.rb file the module  
loads up fine. I am definitely running under the dev environment and i  
am editing the correct rb file as far as I can tell. Any ideas?

Thanks.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 9, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/environment-rb-ruby-path-issue/125525/2 "2008-01-09T23:03:03Z")

</div>

Ed wrote:

> I’m attempting to add a path to my rails app by adding the line :  
> config.load\_paths += %W( #{RAILS\_ROOT}/new\_path )  
> to my config/environments/development.rb file. For some reason rails  
> doesn’t seem to be picking up the module located in this path, however  
> when I add that same line to my config/environment.rb file the module  
> loads up fine. I am definitely running under the dev environment and i  
> am editing the correct rb file as far as I can tell. Any ideas?
> 
> Thanks.

I don’t think you can use an environment-specific initializer. The  
initializer defined in environment.rb is run before any  
environment-specific code.

See  
[http://toolmantim.com/article/2006/12/27/environments\_and\_the\_rails\_initialisation\_process](http://toolmantim.com/article/2006/12/27/environments_and_the_rails_initialisation_process),  
the section titled “Rails::Initializer.run and per-environment configs”.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 10, 2008, 6:46pm UTC](https://www.ruby-forum.com/t/environment-rb-ruby-path-issue/125525/3 "2008-01-10T18:46:12Z")

</div>

I see. Let me explain what I’m trying to do any maybe you have some  
advice.  
I’ve got two ruby modules that have the same name and same  
functionality but are  
implemented differently. I’d like one of them to be loaded by ruby  
depending on  
the environment. I don’t want to make any changes to config/  
environment.rb and would  
like to keep environment specific changes confined to config/  
environments/\*.rb.  
What should I be doing to accomplish this?

Thanks a lot.

On Jan 9, 5:03 pm, Jeremy Weiskotten \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 10, 2008, 6:48pm UTC](https://www.ruby-forum.com/t/environment-rb-ruby-path-issue/125525/4 "2008-01-10T18:48:33Z")

</div>

I see. Let me explain what I’m trying to do any maybe you have some  
advice. I’ve got two ruby modules that have the same name and same  
functionality but are implemented differently. I’d like one of them to  
be loaded by ruby depending on the environment. I don’t want to make  
any changes to config/environment.rb and would like to keep  
environment specific changes confined to config/environments/\*.rb.  
What should I be doing to accomplish this?

Thanks a lot.

On Jan 9, 5:03 pm, Jeremy Weiskotten \<rails-mailing-l…@andreas-
