# Newbe:Where declare constants visible in view & controller?

**URL:** <https://www.ruby-forum.com/t/newbe-where-declare-constants-visible-in-view-controller/97505>\
**Category:** Rails\
**Created:** [January 26, 2006, 10:50am UTC](https://www.ruby-forum.com/t/newbe-where-declare-constants-visible-in-view-controller/97505 "2006-01-26T10:50:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cneuhaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/34f0e0/32.png) [@cneuhaus](https://www.ruby-forum.com/u/cneuhaus)\
**Post date:** [January 26, 2006, 10:50am UTC](https://www.ruby-forum.com/t/newbe-where-declare-constants-visible-in-view-controller/97505/1 "2006-01-26T10:50:01Z")

</div>

I am using some constants that should be visible in the controller and  
in a view.

Declaring the constant in the controller does not make the constant  
visible in the view.

So my question:  
Where can I declare the constant to be visible in all views and  
controllers ?

Thanks a lot in advance  
Christian

---

<div class="post-metadata">

**Author:** ![cneuhaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/34f0e0/32.png) [@cneuhaus](https://www.ruby-forum.com/u/cneuhaus)\
**Post date:** [January 27, 2006, 9:15am UTC](https://www.ruby-forum.com/t/newbe-where-declare-constants-visible-in-view-controller/97505/2 "2006-01-27T09:15:15Z")

</div>

Hi,  
I know its a simple question - but maybe someone can help 🙂  
Thanks  
Christian

Christian Neuhaus wrote:

> I am using some constants that should be visible in the controller and  
> in a view.
> 
> Declaring the constant in the controller does not make the constant  
> visible in the view.
> 
> So my question:  
> Where can I declare the constant to be visible in all views and  
> controllers ?
> 
> Thanks a lot in advance  
> Christian

---

<div class="post-metadata">

**Author:** ![cneuhaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/34f0e0/32.png) [@cneuhaus](https://www.ruby-forum.com/u/cneuhaus)\
**Post date:** [January 27, 2006, 6:18pm UTC](https://www.ruby-forum.com/t/newbe-where-declare-constants-visible-in-view-controller/97505/3 "2006-01-27T18:18:41Z")

</div>

Set a instance attribute in the controller via before\_filter.

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![cneuhaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/34f0e0/32.png) [@cneuhaus](https://www.ruby-forum.com/u/cneuhaus)\
**Post date:** [January 27, 2006, 6:58pm UTC](https://www.ruby-forum.com/t/newbe-where-declare-constants-visible-in-view-controller/97505/4 "2006-01-27T18:58:05Z")

</div>

On Jan 27, 2006, at 12:15 AM, Christian Neuhaus wrote:

> > Declaring the constant in the controller does not make the constant  
> > visible in the view.
> > 
> > So my question:  
> > Where can I declare the constant to be visible in all views and  
> > controllers ?
> > 
> > Thanks a lot in advance  
> > Christian

Christain-

```
I usually put my constants in the environment.rb file. This way they

```

will be available everywhere in the whole app. just remember to  
restart the webserver after makig changes to them.

Cheers-  
-Ezra Z.  
Yakima Herald-Republic  
WebMaster

> **[yakimaherald.com | Yakima, Washington - We Tell Your Stories](https://www.yakimaherald.com/)**

509-577-7732  
removed\_email\_address@domain.invalid
