Created
May 12, 2015 19:03
-
-
Save stochastic-thread/8d09600e8d742beffc43 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
defmodule Thinker.User do | |
use Thinker.Web, :model | |
schema "users" do | |
field :username, :string | |
timestamps | |
end | |
@required_fields ~w(username) | |
@optional_fields ~w() | |
@doc """ | |
Creates a changeset based on the `model` and `params`. | |
If `params` are nil, an invalid changeset is returned | |
with no validation performed. | |
""" | |
def changeset(model, params \\ nil) do | |
model | |
|> cast(params, @required_fields, @optional_fields) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error message: