Skip to content

Instantly share code, notes, and snippets.

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 jeremytregunna/6195f6b6a48ca1e47bcb94b5976dcd03 to your computer and use it in GitHub Desktop.
Save jeremytregunna/6195f6b6a48ca1e47bcb94b5976dcd03 to your computer and use it in GitHub Desktop.
def create_changeset(struct, params \\ %{}) do
struct
|> cast(params, ~w(user_id))
|> cast_assoc(:user)
|> validate_required(~w(user_id)a)
end
def grant_changeset(struct) do
struct
|> cast(%{decision: true}, ~w(decision)a)
end
def revoke_changeset(struct) do
struct
|> cast(%{decision: false}, ~w(decision)a)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment