# Something 'required' in environment.rb available to all?

**URL:** <https://www.ruby-forum.com/t/something-required-in-environment-rb-available-to-all/85497>\
**Category:** Rails\
**Created:** [February 14, 2007, 1:24am UTC](https://www.ruby-forum.com/t/something-required-in-environment-rb-available-to-all/85497 "2007-02-14T01:24:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![farhad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bbce88/32.png) [@farhad](https://www.ruby-forum.com/u/farhad)\
**Post date:** [February 14, 2007, 1:24am UTC](https://www.ruby-forum.com/t/something-required-in-environment-rb-available-to-all/85497/1 "2007-02-14T01:24:22Z")

</div>

Hi,

In my environment.rb file I ‘require’ some files. They seem to be  
available to all my .rb files and my application.rhtml, but not to my  
other .rhtml files. Is this an understanding error on my part? If not,  
what’s the best way of making the files accessible to my .rthml files?

Thanks

---

<div class="post-metadata">

**Author:** ![farhad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bbce88/32.png) [@farhad](https://www.ruby-forum.com/u/farhad)\
**Post date:** [February 14, 2007, 1:29am UTC](https://www.ruby-forum.com/t/something-required-in-environment-rb-available-to-all/85497/2 "2007-02-14T01:29:17Z")

</div>

On 2/13/07, Farhad [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

Add include statements into your application\_helper.rb to give access to  
modules/classes that you have required in your environment.rb.

–  
Andrew S.

---

<div class="post-metadata">

**Author:** ![farhad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bbce88/32.png) [@farhad](https://www.ruby-forum.com/u/farhad)\
**Post date:** [February 14, 2007, 1:36am UTC](https://www.ruby-forum.com/t/something-required-in-environment-rb-available-to-all/85497/3 "2007-02-14T01:36:15Z")

</div>

Thanks Andrew,

Aren’t the include statements just so that you can merge the namespaces?  
Shouldn’t I just be able to do something like: RequiredModule::Constant  
to access that constant for the module that was required?

In any case, I have added the “include RequiredModule” in my  
caller\_helper.rb class, and I still can’t access the constant.

Andrew S. wrote:

> On 2/13/07, Farhad [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Thanks
> > 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > >
> 
> Add include statements into your application\_helper.rb to give access to  
> modules/classes that you have required in your environment.rb.
> 
> –  
> Andrew S.

---

<div class="post-metadata">

**Author:** ![farhad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bbce88/32.png) [@farhad](https://www.ruby-forum.com/u/farhad)\
**Post date:** [February 14, 2007, 1:43am UTC](https://www.ruby-forum.com/t/something-required-in-environment-rb-available-to-all/85497/4 "2007-02-14T01:43:15Z")

</div>

OK - pilot error. Problem is that I had added the constant and not  
re-set the server. The server only sources the files once if they’re  
done in environment.rb.

Farhad wrote:

> Thanks Andrew,
> 
> Aren’t the include statements just so that you can merge the namespaces?  
> Shouldn’t I just be able to do something like: RequiredModule::Constant  
> to access that constant for the module that was required?
> 
> In any case, I have added the “include RequiredModule” in my  
> caller\_helper.rb class, and I still can’t access the constant.
> 
> Andrew S. wrote:
> 
> > On 2/13/07, Farhad [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > 
> > > Thanks
> > > 
> > > –  
> > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > > 
> > > >
> > 
> > Add include statements into your application\_helper.rb to give access to  
> > modules/classes that you have required in your environment.rb.
> > 
> > –  
> > Andrew S.
