defmodule Officetournament.League do
  use Officetournament.Web, :model

  schema "leagues" do
    field :name, :string

    timestamps
  end

  @required_fields ~w(name)
  @optional_fields ~w()

  @doc """
  Creates a changeset based on the `model` and `params`.

  If no params are provided, an invalid changeset is returned
  with no validation performed.
  """
  def changeset(model, params \\ :empty) do
    model
    |> cast(params, @required_fields, @optional_fields)
  end
end

defmodule Officetournament.League do
  use Officetournament.Web, :model

  schema "leagues" do
    field :name, :string
    has_many :memberships, Officetournament.Membership

    timestamps
  end

  @required_fields ~w(name)
  @optional_fields ~w()

  @doc """
  Creates a changeset based on the `model` and `params`.

  If no params are provided, an invalid changeset is returned
  with no validation performed.
  """
  def changeset(model, params \\ :empty) do
    model
    |> cast(params, @required_fields, @optional_fields)
  end
end

Add has_many memberships for League
Add has_many memberships for League

X0nic/officetournament,X0nic/officetournament