Phoenix 1.3.0 generated the following something.ex
file when I ran mix phx.gen.schema MyContext.Something somethings name whatever
.
defmodule MyApp.MyContext.Something do
use Ecto.Schema
import Ecto.Changeset
alias MyApp.MyContext.Something
schema "somethings" do
field :name, :string
field :whatever, :string
timestamps()
end
@doc false
def changeset(%Something{} = something, attrs) do
something
|> cast(attrs, [:name, :whatever])
|> validate_required([:name, :whatever])
end
end
But now Phoenix 1.3.2 generates the following something.ex
file when I ran the same command.
defmodule MyApp.MyContext.Something do
use Ecto.Schema
import Ecto.Changeset
schema "somethings" do
field :name, :string
field :whatever, :string
timestamps()
end
@doc false
def changeset(something, attrs) do
something
|> cast(attrs, [:name, :whatever])
|> validate_required([:name, :whatever])
end
end
tldr; The Alias for MyContext.Something
is removed and the first argument inside changeset function changes from %Something{} = something
to something
.
When I tested to insert some values from the iex
, it behaved like previously, but I wonder what changed under the hood and why?
I’d love if @chrismccord or someone else from the Phoenix core team tell me, how and why this change was made.
Thank you!