# `Waffle.Ecto.Schema`

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

# `cast_attachments`
*macro* 

Extracts attachments from params and converts it to the accepted format.

## Options

  * `:allow_urls` — fetches remote file if the string matches `~r/^https?:\/\//`
  * `:allow_paths` — accepts any local path as file destination

## Examples

    cast_attachments(changeset, params, [:fetched_remote_file], allow_urls: true)

# `check_and_apply_scope`

# `convert_params_to_binary`

# `do_apply_changes`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
