Default value for a field in changeset (use ecto schema default)

August 10, 2018

Set a default value for an ecto schema like so:

defmodule Track.Time.Log do
  use Ecto.Schema
  import Ecto.Changeset

  schema "logs" do
    # ... other fields
    field(:billable, :boolean, default: true)
  end
end

Made it this far? Have a go at the game of snake