Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 21, 2016 19:02
Show Gist options
  • Save bnhansn/2eac049b6c981cf9365b98bdf9db1d24 to your computer and use it in GitHub Desktop.
Save bnhansn/2eac049b6c981cf9365b98bdf9db1d24 to your computer and use it in GitHub Desktop.
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