【问题标题】:Can't generate model in phoenix无法在phoenix中生成模型
【发布时间】:2020-10-08 21:23:13
【问题描述】:

按照这里的教程进行操作

https://www.youtube.com/watch?v=THUG8J3xSYw&list=PLtTtLKRL6UYGxOHToRYnXBynon5plZ7Jd&index=1

尝试使用脚手架生成模型。

我在终端上试过这个

mix phx.gen.model Comment comments body:text post_id:references:posts

但我在终端中得到以下信息:

** (Mix) The task "phx.gen.model" could not be found. Did you mean "phx.gen.html"?

我在终端上试过了

mix phoenix.gen.model Comment comments body:text post_id:references:posts

但我在终端中得到以下信息:

** (Mix) The task "phoenix.gen.model" could not be found

【问题讨论】:

  • 本教程已经过时了,我建议使用更新的资源。如果您想了解更多关于 1.3 中模型被替换为上下文的原因,可以查看this talk。

标签: elixir phoenix-framework


【解决方案1】:

在 1.3 中,模型已被弃用。现在是架构

mix phx.gen.schema Comment comments body:text post_id:references:posts

【讨论】:

  • 一般来说,在这种情况下,您通常应该查看mix help - 它会列出可用的任务。您也可以mix help phx.gen.schema 获取有关特定任务的更多信息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多