$ mix phx.new blog
$ cd blog
$ mix ecto.create
$ mix phx.gen.html Blog Post posts title body:text
$ vim lib/blog_web/router.ex # adding the route
$ mix ecto.migrate
$ mix phx.new blog
$ cd blog
$ mix ecto.create
$ mix phx.gen.html Blog Post posts title body:text
$ vim lib/blog_web/router.ex # adding the route
$ mix ecto.migrate
Compiling 6 files (.ex)
== Compilation error in file lib/blog_web/controllers/post_controller.ex ==
** (CompileError) lib/blog_web/controllers/post_controller.ex:13: Blog.Blog.Blog.Post.__struct__/1 is undefined, cannot expand struct Blog.Blog.Blog.Post
lib/blog_web/controllers/post_controller.ex:12: (module)
(stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
If mix phx.new blog and mix phx.gen.html Blog Post posts title body:text don't mix then there should be an error message from mix phx.gen.html. Alternatively it should work without the error afterwords.
Error is caused by:
alias Blog.Blog
alias Blog.Blog.Post
When alias Blog.Blog.Post is called, because Blog.Blog is already aliased, Blog references Blog.Blog and Post becomes Blog.Blog.Blog.Post
Yeah, we should not allow someone to create a context with the same name as the app.
Looks like a new rule in validate_args! would be a good fit
José Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Director of R&D
I would like to implement that.
Any suggestions about the message would be great) but we can discuss it later
“Cannot generate context Blog because it has the same name as the
application”
José Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Director of R&D
Most helpful comment
Error is caused by:
When
alias Blog.Blog.Postis called, becauseBlog.Blogis already aliased,BlogreferencesBlog.BlogandPostbecomesBlog.Blog.Blog.Post