# Where to put array to be shared across models

**URL:** <https://www.ruby-forum.com/t/where-to-put-array-to-be-shared-across-models/86857>\
**Category:** Rails\
**Created:** [March 24, 2006, 5:47pm UTC](https://www.ruby-forum.com/t/where-to-put-array-to-be-shared-across-models/86857 "2006-03-24T17:47:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [March 24, 2006, 5:47pm UTC](https://www.ruby-forum.com/t/where-to-put-array-to-be-shared-across-models/86857/1 "2006-03-24T17:47:34Z")

</div>

Quick question: I have an array of reserved words that I want to share  
across most of my models so I can do something like this in the models:

validates\_exclusion\_of :username, :in =\> RESERVED\_WORDS, :message =\>  
“This  
username is a reserved word. Please choose another.”

Here is a sampling of the the array:  
RESERVED\_WORDS = %w( blog blogs forum forums search login logout signup  
signout register help store )

Should I just subclass AR and then extend my models from this base class  
or  
is there a way to stick it in one of the config files like  
environment.rb?

Thanks,  
Zack

---

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [March 24, 2006, 6:11pm UTC](https://www.ruby-forum.com/t/where-to-put-array-to-be-shared-across-models/86857/2 "2006-03-24T18:11:00Z")

</div>

Yes, you can put constants in environment.rb and they’ll be available  
everywhere.

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [March 24, 2006, 6:45pm UTC](https://www.ruby-forum.com/t/where-to-put-array-to-be-shared-across-models/86857/3 "2006-03-24T18:45:05Z")

</div>

Thanks Tom. I thought that would be the easiest. I just didn’t know if  
it  
is the “best practices” way to do it.

Thanks again,  
Zack
