Created
December 31, 2017 02:37
-
-
Save elderbas/10e8ae6873bb9b0b52eeb489da2e4f42 to your computer and use it in GitHub Desktop.
Person module
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 MyApp.Person do | |
use MyApp.Web, :model | |
schema "people" do | |
field :name, :string | |
timestamps() | |
end | |
@doc """ | |
Builds a changeset based on the `struct` and `params`. | |
""" | |
def changeset(struct, params \\ %{}) do | |
struct | |
|> cast(params, [:name]) | |
|> validate_required([:name]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment