Created
October 21, 2016 19:02
-
-
Save bnhansn/2eac049b6c981cf9365b98bdf9db1d24 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.UserRoom do | |
| use Sling.Web, :model | |
| schema "user_rooms" do | |
| belongs_to :user, Sling.User | |
| belongs_to :room, Sling.Room | |
| timestamps() | |
| end | |
| def changeset(struct, params \\ %{}) do | |
| struct | |
| |> cast(params, [:user_id, :room_id]) | |
| |> validate_required([:user_id, :room_id]) | |
| |> unique_constraint(:user_id_room_id) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment