# How to put common utils in the app without polluing environm

**URL:** <https://www.ruby-forum.com/t/how-to-put-common-utils-in-the-app-without-polluing-environm/83509>\
**Category:** Rails\
**Created:** [January 26, 2007, 7:17pm UTC](https://www.ruby-forum.com/t/how-to-put-common-utils-in-the-app-without-polluing-environm/83509 "2007-01-26T19:17:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 26, 2007, 7:17pm UTC](https://www.ruby-forum.com/t/how-to-put-common-utils-in-the-app-without-polluing-environm/83509/1 "2007-01-26T19:17:26Z")

</div>

I have developed some common utils which I use in all my RoR apps.  
It’s a moule with a lot of utilities. In order t use them currently  
this is what I do.

environment.rb  
include AppCommonUtils

The file app\_common\_utils reside in lib directory. It works but I don’t  
like it.

In order to use these utilities I need to tinker with the  
environment.rb of each application. So I put this module as a pluging.  
But in int init.rb of the plugin I don’t know what to write which will  
be equivalent of putting the module in the environment.rb.

I’m suspecting it will be something along the line of

something.send(:include, AppCommonUtils)

Could someone help me out with what that something should be here?

Thanks

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 29, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/how-to-put-common-utils-in-the-app-without-polluing-environm/83509/2 "2007-01-29T16:49:51Z")

</div>

> In order to use these utilities I need to tinker with the  
> environment.rb of each application. So I put this module as a pluging.  
> But in int init.rb of the plugin I don’t know what to write which will  
> be equivalent of putting the module in the environment.rb.
> 
> I’m suspecting it will be something along the line of
> 
> something.send(:include, AppCommonUtils)

Rails will load your AppCommonUtils module automatically without your  
having to tinker with environment.rb.

If you want to include your module, i.e. above and beyond the  
auto-‘require’ I just mentioned, you could try something like this  
(though I’m not 100% sure about this) inside your module:

module AppCommonUtils  
def self.included(base)  
base.extend self  
end  
end

Regards,  
Andy S.

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [January 31, 2007, 3:30am UTC](https://www.ruby-forum.com/t/how-to-put-common-utils-in-the-app-without-polluing-environm/83509/3 "2007-01-31T03:30:19Z")

</div>

The module AppCommonUtils needs to be included in environment.rb for  
it to be invoked. Otherwise I don’t think it’ll work.

- Neeraj
