How do you store custom constants in Rails 4?

Viewed 7236

I made some regular expressions for email, bitmessage etc. and put them as constants to

#config/initializers/regexps.rb
REGEXP_EMAIL = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
REGEXP_BITMESSAGE = /\ABM-[a-zA-Z1-9&&[^OIl]]{32,34}\z/

and use it like

if @user.contact =~ REGEXP_EMAIL
elsif @user.contact =~ REGEXP_BITMESSAGE

Is that's good practice? What's the best way to store them?

1 Answers
Related