Skip to content

Instantly share code, notes, and snippets.

@FreedomBen
Created December 31, 2020 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FreedomBen/19bbe85182eefc03b0678b26ae0d1325 to your computer and use it in GitHub Desktop.
Save FreedomBen/19bbe85182eefc03b0678b26ae0d1325 to your computer and use it in GitHub Desktop.
Part of my IEx config file
#
# This module defines some handy functions for use in iex
#
defmodule DebugTools do
@doc ~S"""
Cast all the params provided here into an Ecto.Changeset.
This defeats Ecto's whitelist approach so you should never use this in real code!
It's intended as a debug tool for use in tests of IEx sessions.
"""
def ecto_cast_all(data, params, opts \\ []),
do: Ecto.Changeset.cast(data, params, Map.keys(params), opts)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment