I run some code with iex -S mix
This is ok:
user = Repo.get User, 1
Ecto.Changeset.change user, %{name: "xxxx"}
but this is wrong:
User.change user, %{name: "xxxx"}
raise (UndefinedFunctionError) undefined function Rumbl.User.change/2
I notice there is import Ecto.Changeset
in function model in file web.ex
def model do
quote do
use Ecto.Schema
import Ecto
import Ecto.Changeset
import Ecto.Query, only: [from: 1, from: 2]
end
end
So I think User.change/2 should works as same as Ecto.Changeset.change/2, is it right?