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)
You must be logged in to comment