phoenix undefined function changeset/3
<p>I study the framework phoenix.
Is a model of the image that will be stored in the cloud storage. When creating an image I calculate the hash of the file, and take it as a :name. I made a model, controller and view. But I do not understand why I receive an error:</p>

<pre><code>== Compilation error on file web/models/image.ex ==
** (CompileError) web/models/image.ex:26: undefined function changeset/3
    (stdlib) lists.erl:1338: :lists.foreach/2
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (elixir) lib/kernel/parallel_compiler.ex:116: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
</code></pre>

<p>I have reviewed all of your code, but did not find the place where I call Image.changeset with three parameters. 
My image.ex:</p>

<pre><code>defmodule Blog.Image do
  use Blog.Web, :model

  schema "images" do
    field :name, :string
    field :original_name, :string
    field :filename, :string, virtual: true

    timestamps
  end

  @required_fields ~w(
    name
    original_name
    filename
  )
  @optional_fields ~w()

  def changeset(struct, params \\ %{}) do
    struct
    |&gt; cast(params, @required_fields, @optional_fields)
  end

  def create_changeset(struct, params \\ %{}) do
    struct
    |&gt; changeset(struct, params)
    |&gt; generate_name_hash
  end

  defp generate_name_hash(changeset) do
    put_change(changeset, :name, gen_hash_name(changeset[:filename]))
  end

  defp gen_hash_name(filename) do
    hash_name = :crypto.hash(:sha256, File.read(filename))
    |&gt; Base.encode16
    "/"&lt;&gt;slice(hash_name, 0, 2)&lt;&gt;"/"&lt;&gt;slice(hash_name, 2, 2)&lt;&gt;"/"&lt;&gt;slice(hash_name, 4, 2)
  end

end
</code></pre>

<p>my image_controller.ex:</p>

<pre><code>defmodule Blog.ImageController do
  use Blog.Web, :controller
  plug Addict.Plugs.Authenticated when action in [:new, :create]

  def new(conn, _params) do
    changeset = Blog.Image.changeset(%Blog.Image{})
    render conn, "new.html", changeset: changeset
  end

  def create(conn, %{"image" =&gt; image_params}) do
    full_image_params = %{filename: image_params["image"].path, original_name: image_params["image"].filename}
    changeset = Blog.Image.create_changeset(%Blog.Image{}, full_image_params)
    case Blog.Repo.insert(changeset) do
      {:ok, image} -&gt;
        conn
        |&gt; put_flash(:info, "Image created successfully.")
        |&gt; redirect(to: image_path(conn, :show, image))
      {:error, changeset} -&gt;
        render(conn, "new.html", changeset: changeset)
    end
  end
end
</code></pre>

<p>my new.html.eex:</p>

<pre><code>&lt;%= form_for @changeset, image_path(@conn, :create), [role: "form", multipart: true], fn f -&gt; %&gt;
  &lt;div class="form-group"&gt;
    &lt;%= label f, :image, class: "control-label" %&gt;
    &lt;%= file_input f, :image, class: "form-control" %&gt;
    &lt;%= error_tag f, :image %&gt;
  &lt;/div&gt;
  &lt;div class="container"&gt;
    &lt;div class="form-group"&gt;
      &lt;%= submit "Submit", class: "btn btn-default" %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;% end %&gt;
</code></pre>