small medium large xlarge

22 Nov 2017, 01:00
Stefan Chrobot (14 posts)

Just a friendly reminder that the book seems to have been written for Ecto 1.x. If you follow along, and use Phoenix 1.2.x, it might pull Ecto 2.0 where there’s a breaking API change in the cast function: v2.0 CHANGELOG. This means that the changeset functions on models need to be adjusted. For example, for user.ex it should be:

  def changeset(model, params \\ %{}) do
    |> cast(params, [:name, :username])
    |> validate_required([:name, :username])
    |> validate_length(:username, min: 1, max: 20)
    |> unique_constraint(:username)
18 Mar 2018, 22:28
Randy Pond (4 posts)

Yes, thanks for this update.

I had lots of problems in Chapter 4 when trying to get the validation errors to show up in the form. This fixes it.

IMO This might need an update for the book.

You must be logged in to comment