-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathskill.ex
More file actions
30 lines (24 loc) · 750 Bytes
/
skill.ex
File metadata and controls
30 lines (24 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
defmodule CodeCorps.Skill do
use CodeCorps.Web, :model
@type t :: %__MODULE__{}
schema "skills" do
field :title, :string
field :description, :string
field :original_row, :integer
has_many :role_skills, CodeCorps.RoleSkill
has_many :roles, through: [:role_skills, :role]
has_many :project_skills, CodeCorps.ProjectSkill
has_many :user_skills, CodeCorps.UserSkill
has_many :projects, through: [:project_skills, :project]
timestamps()
end
@doc """
Builds a changeset based on the `struct` and `params`.
"""
def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:title, :description, :original_row])
|> validate_required([:title])
|> unique_constraint(:title)
end
end