How to store array with Ecto using Postgres
I found the answer in the list of primitive types for Ecto.Schema here: Ecto.Schema The answer is to define the type like this: schema “my_model” do field :my_array, {:array, :float} timestamps end
I found the answer in the list of primitive types for Ecto.Schema here: Ecto.Schema The answer is to define the type like this: schema “my_model” do field :my_array, {:array, :float} timestamps end
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.
Ah, the famous pokemon route: get “/*path” You will find the paths inside conn.params[“path”] or as conn.path_info.
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
You can run iex -S mix to run iex with the dependencies in your current mix project included.. You can read about this at http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html From there you can execute Ecto queries: iex> MyApp.Repo.all(MyApp.User) Running iex -S mix phx.server will also start the phoenix server.
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