Forum: Ruby on Rails Where to put array to be shared across models.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C4dc94c893471878a105761a9207f29b?d=identicon&s=25 Zack Chandler (Guest)
on 2006-03-24 17:47
(Received via mailing list)
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
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-03-24 18:11
(Received via mailing list)
Yes, you can put constants in environment.rb and they'll be available
everywhere.

--
-- Tom Mornini
C4dc94c893471878a105761a9207f29b?d=identicon&s=25 Zack Chandler (Guest)
on 2006-03-24 18:45
(Received via mailing list)
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
This topic is locked and can not be replied to.