Evan Conrad
Evan Conrad

Reputation: 4389

Why is phoenix_ecto failing to compile on the :model in the changeset?

When I try to run mix deps.get or mix deps.compile I get this error:

== Compilation error on file lib/phoenix_ecto/html.ex ==
** (CompileError) lib/phoenix_ecto/html.ex:3: unknown key :model for struct Ecto.Changeset
    (stdlib) lists.erl:1354: :lists.mapfoldl/3

Why is this happening and how can I fix it?

Upvotes: 2

Views: 588

Answers (1)

Evan Conrad
Evan Conrad

Reputation: 4389

How to fix this:

You need to upgrade your dependencies like so:

{:ecto, "~> 2.0.4"},
{:phoenix_ecto, "~> 3.0.1"},
{:phoenix_html, "~> 2.6.2"},

Then run mix clean --all and then mix deps.get.

Why this is happening:

This error comes from your phoenix_ecto dependency being behind your ecto dependency. In ecto v2.0.0, changeset.model became changeset.data.

The code for phoenix_ecto is still using model on line three:

def to_form(%Ecto.Changeset{model: model, params: params} = changeset, opts) do

In this commit, phoenix_ecto was upgraded to support the new version of ecto.

Upvotes: 7

Related Questions