Files
rsh26_pool_example/lib/rsh26pool/voting/idea.ex
T

28 lines
738 B
Elixir
Raw Normal View History

2026-07-04 19:27:17 +09:00
defmodule Rsh26pool.Voting.Idea do
@moduledoc """
A voting option. In normal mode it is an idea posted by a participant; in
grouping mode it is the participant's opinion (one per participant).
"""
use Ecto.Schema
import Ecto.Changeset
alias Rsh26pool.Voting.{Participant, Room, Vote}
schema "ideas" do
field :text, :string
belongs_to :room, Room
belongs_to :participant, Participant
has_many :votes, Vote
timestamps(type: :utc_datetime)
end
def changeset(idea, attrs) do
idea
|> cast(attrs, [:text])
|> validate_required([:text], message: "内容を入力してください")
|> validate_length(:text, max: 200, message: "200文字以内で入力してください")
end
end