# To Use or not to use global variable

**URL:** <https://www.ruby-forum.com/t/to-use-or-not-to-use-global-variable/152588>\
**Category:** Rails\
**Created:** [November 5, 2008, 11:39am UTC](https://www.ruby-forum.com/t/to-use-or-not-to-use-global-variable/152588 "2008-11-05T11:39:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [November 5, 2008, 11:39am UTC](https://www.ruby-forum.com/t/to-use-or-not-to-use-global-variable/152588/1 "2008-11-05T11:39:24Z")

</div>

Hi  
My application has facility that any user can create a ticket from  
the intranet site.So upon creating a ticket he gives an email id .And I  
have to send mail back to this mail id giving created ticket’s  
information…My application is running on differnt ports (say 3000 and  
3001 or example) Both for two companies…So as part of ticket creation  
email to be send to removed\_email\_address@domain.invalid(if it created from company 1  
intranet), and similarly removed\_email\_address@domain.invalid it created from company 2  
intranet…here removed\_email\_address@domain.invalid and removed\_email\_address@domain.invalid are text boxes  
eneterd by the user  
So where will I store the portion after @ (company1,company2) .Is  
it inside a global variable by reading it from a yml file?This I am  
doing to change code for second company…I think you understand the  
problem

```
  And also one thing Suppose if I store it in a yml file can I call

```

this only once when I enter in to the controller …As far I undestod  
before\_filer is called = no of times specified action is called

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [November 5, 2008, 5:43pm UTC](https://www.ruby-forum.com/t/to-use-or-not-to-use-global-variable/152588/2 "2008-11-05T17:43:29Z")

</div>

On Nov 5, 2008, at 2:39 AM, Sijo Kg wrote:

> company 2  
> intranet…here removed\_email\_address@domain.invalid and removed\_email\_address@domain.invalid are text boxes  
> eneterd by the user  
> So where will I store the portion after @ (company1,company2) .Is  
> it inside a global variable by reading it from a yml file?This I am  
> doing to change code for second company…I think you understand the  
> problem
> 
> ```
> And also one thing Suppose if I store it in a yml file can I call
> 
> ```
> 
> this only once when I enter in to the controller …As far I undestod  
> before\_filer is called = no of times specified action is called

Start here.

[http://agilewebdevelopment.com/plugins/application\_config](http://agilewebdevelopment.com/plugins/application_config)

‘application\_config’ eases project configuring by introducing yaml  
config file in RAILS\_ROOT/config folder and provides handful methods  
accessing config values based on current rails environment. So, you  
can have separate sets of configuration properties for each rails  
environment you use.
