Am getting that error

ompilation error in file lib/discuss_web/models/topic.ex ==
** (CompileError) lib/discuss_web/models/topic.ex:2: undefined function use/0
    (stdlib) lists.erl:1354: :lists.mapfoldl/3
    expanding macro: DiscussWeb.__using__/1
    lib/discuss_web/models/topic.ex:2: DiscussWeb.Topic (module)
    (elixir) expanding macro: Kernel.use/2
    lib/discuss_web/models/topic.ex:2: DiscussWeb.Topic (module)
    (elixir) lib/kernel/parallel_compiler.ex:229: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

Please show this file…

defmodule DiscussWeb.Topic do

    use DiscussWeb, :model

     schema "topics" do

         field :title, :string

     end

     def changeset(struct, params \\ %{}) do

        struct 

        |> cast(params, [:title])

        |> validate_reguired([:title])

     end

 end

Your line 2 is empty…

Though I guess that those blank lines are from some copy and paste stuff and assume that your second line is use DiscussWeb, :model, which looks fine on a first glance.

My bet is that You are following an old tuto, with the newer Phoenix.

Using DiscussWeb is a sign of Phoenix 1.3+

Using :model is a sign of Phoenix 1.2

1 Like