Skip to content

Instantly share code, notes, and snippets.

@Hajto
Created December 8, 2016 17:16
Show Gist options
  • Save Hajto/f396fe01f11af5f38a0aec4d97df93c8 to your computer and use it in GitHub Desktop.
Save Hajto/f396fe01f11af5f38a0aec4d97df93c8 to your computer and use it in GitHub Desktop.
defmodule Kpsz.Event do
use Kpsz.Web, :model
schema "events" do
field :name, :string
field :description, :string
field :location, Kpsz.Point
has_many :pressences, Kpsz.Pressence
timestamps()
end
@doc """
Builds a changeset based on the `struct` and `params`.
"""
def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:name, :description, :location])
|> validate_required([:name, :description, :location])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment