Mur*_*tza 3 elixir phoenix-framework
我想看看凤凰1.3-dev
.我从存储库克隆凤凰,然后按照phoenix/installer/README.md
构建存档.
phoenix/installer/README.md(供参考)
$ cd installer
$ MIX_ENV=prod mix archive.build
$ mix archive.install
Run Code Online (Sandbox Code Playgroud)
我创建了一个新的凤凰应用程序mix phx.new blog
但是当我试图创建一个简单的html脚手架时,mix phx.gen.html Post posts title body:text
我得到以下错误消息:
** (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).
Run Code Online (Sandbox Code Playgroud)
我的问题是为什么要添加context
模块?它有何帮助?如果您对此有所了解,请描述一个用例,以便我能理解.
上下文模块允许我们从控制器中删除Repo调用到他们自己的模块,以便可以在关注点之间分离.
更多信息,请尝试听听Chris McCord的演讲:
https://www.youtube.com/watch?v=tMO28ar0lW8&index=1&list=PLE7tQUdRKcyaMEekS1T32hUw19UxzqBEo
并查看凤凰代码中的评论: