Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

refs #154 Moved Mix.env to config #159

Merged
merged 1 commit into from
Mar 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ use Mix.Config

config :thesis, store: Thesis.EctoStore
config :thesis, Thesis.EctoStore, repo: MyApp.Repo
config :thesis, env: Mix.env

import_config "#{Mix.env}.exs"
4 changes: 3 additions & 1 deletion examples/example-phx-1_3/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use Mix.Config
config :example_phx,
ecto_repos: [ExamplePhx.Repo]

config :example_phx, env: Mix.env

# Configures the endpoint
config :example_phx, ExamplePhxWeb.Endpoint,
url: [host: "localhost"],
Expand Down Expand Up @@ -43,4 +45,4 @@ config :thesis, :notifications,

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
import_config "#{Mix.env}.exs"
2 changes: 1 addition & 1 deletion examples/example-phx-1_3/lib/example_phx/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule ExamplePhx.Application do
supervisor(ExamplePhxWeb.Endpoint, [])
# Start your own worker by calling: ExamplePhx.Worker.start_link(arg1, arg2, arg3)
# worker(ExamplePhx.Worker, [arg1, arg2, arg3]),
] ++ env_children(Mix.env)
] ++ env_children(Application.get_env(:example_phx, :env))

# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
Expand Down
2 changes: 1 addition & 1 deletion lib/thesis/notifications.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Thesis.Notifications do
"other" => []
}
|> notifications_from_host_app(conn, notifications())
|> notifications_regarding_env(Mix.env)
|> notifications_regarding_env(Application.get_env(:thesis, :env))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we fall back to Mix.env if this doesn't exist? For backwards compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! According to this topic: https://elixirforum.com/t/mix-env-in-production-no-longer-produces-nil-but-crashes-mix-state-genserver/16165/6
we shouldn't user Mix in production environment and since version 1.7.2 Mix is not included in compiled application.
And if we haven't this variable in config file Application.get_env just returns nil:
https://hexdocs.pm/elixir/Application.html#get_env/3
So we shouldn't fallback to Mix.env
P.S. before 1.7.2 Mix.env returns nil in production :)

|> notifications_regarding_page(conn.assigns[:thesis_page])
end

Expand Down