It seems as though test.secret.exs
does not load up automatically in the test
environment.
Application.get_env(:my_app, :my_settings)
returns nil
even though my test.secret.exs
contains the following:
use Mix.Config
config :my_app, :my_settings,
setting1: "blah",
setting2: "bleh"
I'm running Elixir 1.4.0.
答案 0 :(得分:1)
INSTALLED_APPS = [
'pages.apps.PagesConfig' # pages.apps.pages fails too
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
由prod.secret.exs
显式加载,此行显示在默认Phoenix应用模板的末尾:
prod.exs
import_config "prod.secret.exs"
默认情况下没有此功能,因此如果您要加载test.exs
,可以在test.secret.exs
末尾添加以下内容:
test.exs
答案 1 :(得分:0)
除了Dogbert的回答,对于那些想要为每个环境加载相应*.secret.exs
文件的DRY解决方案的人,您可以将其放入config/config.exs
:
import_config "#{Mix.env}.secret.exs"
在那里,您可以从每个特定于环境的配置文件中删除import_config
函数调用。