oneshot
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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
|
||||
Reference in New Issue
Block a user