I installed settingslogic and in the configuration file I put the regex for the email as follows:
#config/settings.yml
defaults: &defaults
email_regex: /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
development:
<<: *defaults
# neat_setting: 800
test:
<<: *defaults
production:
<<: *defaults
That I load in devise configuration in this way:
#config/initializers/devise.rb
# Regex to use to validate the email address
# config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
config.email_regexp = eval Settings.email_regex
It works, but what do you think about that eval
? Is it the correct way to convert a string to a regex?