mobilizon.chapril.org-mobil.../lib/mobilizon/media/picture.ex
2019-05-31 18:07:37 +02:00

24 lines
447 B
Elixir

defmodule Mobilizon.Media.Picture do
@moduledoc """
Represents a picture entity
"""
use Ecto.Schema
import Ecto.Changeset
alias Mobilizon.Media.File
alias Mobilizon.Actors.Actor
schema "pictures" do
embeds_one(:file, File, on_replace: :update)
belongs_to(:actor, Actor)
timestamps()
end
@doc false
def changeset(picture, attrs) do
picture
|> cast(attrs, [:actor_id])
|> cast_embed(:file)
end
end