我无法在devise.rb初始化程序中访问ENV变量的任何原因。下面是文件中的代码:
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
config.email_regexp = /@.*\b#{ENV.fetch('EMAIL_DOMAIN')}/
ENV'EMAIL_DOMAIN'在我的.env文件中以及我可以毫无问题地访问的其他变量。
答案 0 :(得分:0)
如果您在Gemfile:development组中使用https://github.com/bkeepers/dotenv,它会将您的env变量加载到Rails app before_configuration回调中。
然后你可以在devise.rb中使用ENV ['MY_VAR'](或者如上所述获取)