【发布时间】:2017-02-25 22:00:28
【问题描述】:
我想看看凤凰1.3-dev。我从repository 克隆了phoenix,并按照phoenix/installer/README.md 构建存档。
phoenix/installer/README.md(供参考)
$ cd installer
$ MIX_ENV=prod mix archive.build
$ mix archive.install
我通过mix phx.new blog 创建了一个新的phoenix 应用程序,但是当我尝试通过mix phx.gen.html Post posts title body:text 创建一个简单的html 脚手架时,我收到以下错误消息:
** (Mix) Expected the schema argument, ":\"Elixir.Company.companies\"", to be a valid module name
mix phx.gen.html and mix phx.gen.json expect a context module name,
followed by singular and plural names of the generated resource, ending
with any number of attributes:
mix phx.gen.html Accounts User users name:string
mix phx.gen.json Accounts User users name:string
The Accounts context serves as the API boundary for the given resource.
Multiple resources may belong to a context and a resource may be
split over distinct contexts (such as Accounts.User and Blog.User).
我的问题是为什么要添加context 模块?它如何以及在哪里有帮助?
如果您对此有所了解,请描述一个用例以便我理解。
【问题讨论】:
-
错误消息本身是不言自明的。业务逻辑中的“实体”不应 100% 精确映射到数据库模型。