Created
June 24, 2018 17:57
-
-
Save jeremytregunna/6195f6b6a48ca1e47bcb94b5976dcd03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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