# How to access constant array of a model inside a view

**URL:** <https://www.ruby-forum.com/t/how-to-access-constant-array-of-a-model-inside-a-view/128876>\
**Category:** Rails\
**Created:** [February 12, 2008, 11:00am UTC](https://www.ruby-forum.com/t/how-to-access-constant-array-of-a-model-inside-a-view/128876 "2008-02-12T11:00:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iqbalhyd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/d78d45/32.png) [@iqbalhyd](https://www.ruby-forum.com/u/iqbalhyd)\
**Post date:** [February 12, 2008, 11:00am UTC](https://www.ruby-forum.com/t/how-to-access-constant-array-of-a-model-inside-a-view/128876/1 "2008-02-12T11:00:47Z")

</div>

Hello All,

```
  I have this array (of, say User's contact preferences) inside the 

```

User  
model.

CONTACT\_PREFERENCES = [“Email”, “Mobile Phone”, “Residence Phone”,  
“Office  
Phone”, “Fax”]

and inside the view (when registering a new user) I have to show them  
inside  
a combo (or a list of check boxes), but when I do something like this

User::CONTACT\_PREFERENCES.each { }

it gives me

Symbol as array index

any ideas how I should achieve a similar effect, Thanks in advance.

–  
Ishaq  
[http://blogs.kahaf.com/ishaq](http://blogs.kahaf.com/ishaq)

- Programming can be fun, so can be cryptography, however they should  
not be  
combined …

---

<div class="post-metadata">

**Author:** ![iqbalhyd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/d78d45/32.png) [@iqbalhyd](https://www.ruby-forum.com/u/iqbalhyd)\
**Post date:** [February 12, 2008, 8:01pm UTC](https://www.ruby-forum.com/t/how-to-access-constant-array-of-a-model-inside-a-view/128876/2 "2008-02-12T20:01:31Z")

</div>

hmm, does that mean there is no way to do it?

On Feb 12, 2008 2:59 PM, Muhammad I. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ishaq  
> [http://blogs.kahaf.com/ishaq](http://blogs.kahaf.com/ishaq)
> 
> - Programming can be fun, so can be cryptography, however they should not  
> be combined …

–  
Ishaq  
[http://blogs.kahaf.com/ishaq](http://blogs.kahaf.com/ishaq)

- Programming can be fun, so can be cryptography, however they should  
not be  
combined …
