【发布时间】:2019-12-19 16:40:10
【问题描述】:
我创建了这个模块:
defmodule Discuss.Topic do
user Discuss.Web, :model
schema "topics" do
field :title, :string
end
def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:title])
|> validate_required([:title])
end
end
我在使用mix phoenix.server时遇到了这个错误
== Compilation error in file web/models/topic.ex ==
** (CompileError) web/models/topic.ex:2: undefined function user/2
(stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
(elixir) lib/kernel/parallel_compiler.ex:229: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7
知道发生了什么吗?我是 Phoenix 和 Elixir 的新手。
【问题讨论】:
-
旁注:考虑使用formatter,缩进4个空格不习惯;这使得代码更难阅读。
标签: elixir phoenix-framework phoenix