Last active
October 20, 2016 20:03
-
-
Save bnhansn/8346fdbd6806b3274b4dfa47abbaf82a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| defmodule Sling.User do | |
| use Sling.Web, :model | |
| schema "users" do | |
| field :username, :string | |
| field :email, :string | |
| field :password_hash, :string | |
| timestamps() | |
| end | |
| def changeset(struct, params \\ %{}) do | |
| struct | |
| |> cast(params, [:username, :email, :password_hash]) | |
| |> validate_required([:username, :email, :password_hash]) | |
| |> unique_constraint(:username) | |
| |> unique_constraint(:email) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment