How to read config variable in Phoenix / Elixir?

The get_env function is part of the Application module from the Elixir/Erlang core. This function returns the value for a specific key in the app’s environment. Considering your configuration, you would access the title property this way: Application.get_env(:my, My.Endpoint)[:title] The third parameter is for passing a default value when the config key doesn’t exist.

How to Log something in Controller when Phoenix Server is running?

Okay, turns out it’s pretty straight forward. You need to require the Logger elixir module in your controller and call one of it’s methods to log your text. defmodule PhoenixApp.TopicController do require Logger def index(conn, params) do Logger.info “Logging this text!” Logger.debug “Var value: #{inspect(params)}” # … end end Supported levels are: :debug – for … Read more

How can I schedule code to run every few hours in Elixir or Phoenix framework?

There is a simple alternative that does not require any external dependencies: defmodule MyApp.Periodically do use GenServer def start_link(_opts) do GenServer.start_link(__MODULE__, %{}) end def init(state) do schedule_work() # Schedule work to be performed at some point {:ok, state} end def handle_info(:work, state) do # Do the work you desire here schedule_work() # Reschedule once more … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)