Skip to content

Instantly share code, notes, and snippets.

@pikender
Last active May 17, 2016 16:41
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 pikender/f47ac3a8defbbe022022a2ca8c8ad9ce to your computer and use it in GitHub Desktop.
Save pikender/f47ac3a8defbbe022022a2ca8c8ad9ce to your computer and use it in GitHub Desktop.
## Changeset Errors in a string
Enum.join(Enum.map(changeset.errors, fn(x) -> {a, b} = x; Atom.to_string(a) <> " " <> b; end), ",")
## Refund
alias Nectar.Repo; alias Nectar.LineItemReturn; alias Nectar.Refund
lr = Repo.get(LineItemReturn, 4) ## Change 4 to relevant id
c = Ecto.build_assoc(lr, :refund)
r = Refund.create_changeset(c, %{"amount" => 20})
r.errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment