Waffle. Ecto. Schema
(waffle_ecto v0.0.13)
Copy Markdown
Defines helpers to work with changeset.
Add a using statement use Waffle.Ecto.Schema to the top of your
ecto schema, and specify the type of the column in your schema as
MyApp.Avatar.Type.
Attachments can subsequently be passed to Waffle's storage though a
Changeset cast_attachments/3 function, following the syntax of
cast/3.
Example
defmodule MyApp.User do
use MyApp.Web, :model
use Waffle.Ecto.Schema
schema "users" do
field :name, :string
field :avatar, MyApp.Uploaders.AvatarUploader.Type
end
def changeset(user, params \\ %{}) do
user
|> cast(params, [:name])
|> cast_attachments(params, [:avatar])
|> validate_required([:name, :avatar])
end
end
Summary
Functions
Extracts attachments from params and converts it to the accepted format.