Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Last active October 20, 2016 20:03
Show Gist options
  • Save bnhansn/8346fdbd6806b3274b4dfa47abbaf82a to your computer and use it in GitHub Desktop.
Save bnhansn/8346fdbd6806b3274b4dfa47abbaf82a to your computer and use it in GitHub Desktop.
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