Created
May 17, 2020 12:37
-
-
Save karlosmid/75e27fbb6a55695277cb662df4b967a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Testivator.CRM.DataFile do | |
@moduledoc """ | |
DataFile schema | |
""" | |
use Testivator.Web, :model | |
use Arc.Ecto.Schema | |
alias Testivator.CRM.Charter | |
alias Testivator.CRM.DataFile | |
schema "datafiles" do | |
field(:file, Testivator.File.Type) | |
belongs_to(:charter, Charter) | |
timestamps() | |
end | |
def changeset(%DataFile{} = datafile, attrs \\ %{}) do | |
datafile | |
|> cast(attrs, [:charter_id]) | |
|> cast_attachments(attrs, [:file]) | |
|> validate_required(:file) | |
|> assoc_constraint(:charter) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment