forked from code-corps/code-corps-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskill.ex
More file actions
27 lines (22 loc) · 675 Bytes
/
skill.ex
File metadata and controls
27 lines (22 loc) · 675 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
defmodule CodeCorps.Skill do
use CodeCorps.Web, :model
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 :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