Created
October 21, 2016 19:04
-
-
Save bnhansn/305582ca3604fa03c6b6674aed18cde1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Sling.Room do | |
| use Sling.Web, :model | |
| schema "rooms" do | |
| field :name, :string | |
| field :topic, :string | |
| many_to_many :users, Sling.User, join_through: "user_rooms" | |
| timestamps() | |
| end | |
| def changeset(struct, params \\ %{}) do | |
| struct | |
| |> cast(params, [:name, :topic]) | |
| |> validate_required([:name]) | |
| |> unique_constraint(:name) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment