Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 22, 2016 12:05
Show Gist options
  • Save bnhansn/8f7744ee7380691cfd7f105955f6f9d2 to your computer and use it in GitHub Desktop.
Save bnhansn/8f7744ee7380691cfd7f105955f6f9d2 to your computer and use it in GitHub Desktop.
defmodule Sling.Message do
use Sling.Web, :model
schema "messages" do
field :text, :string
belongs_to :room, Sling.Room
belongs_to :user, Sling.User
timestamps()
end
def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:text, :user_id, :room_id])
|> validate_required([:text, :user_id, :room_id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment