Phoenix 1.3 (Elixir) error: Myapp.Users.User .__ struct __ / 0 - undefined, cannot deploy struct Myapp.Users.User

Trying to create an API using Phoenix v1.3 by following this guide:
https://dreamconception.com/tech/phoenix-full-fledged-api-in-five-minutes
(follow each step to the letter)

When I try to run mix ecto.setup

I get the following error: error

 Compiling 17 files (.ex) == Compilation error on file lib/myapp/users/users.ex == ** (CompileError) lib/myapp/users/users.ex:65: Myapp.Users.User.__struct__/0 is undefined, cannot expand struct Myapp.Users.User (stdlib) lists.erl:1354: :lists.mapfoldl/3 lib/myapp/users/users.ex:65: (module) (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6 (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1 

lib/myapp/users/users.ex pretty big: https://github.com/nelsonic/phoenix-api-example/blob/master/lib/myapp/users/users.ex#L65

Full code on GitHub: https://github.com/nelsonic/phoenix-api-example

Any help in debugging it would be greatly appreciated.

+8
data-structures elixir phoenix-framework
source share
1 answer

So there are a few things that I notice:

  • You named your context after recording. You have to name your context after the idea that the notes enter. Something like Authentication or Account

  • Creating # 1, in the Phoenix 1.3 application, where you have an Account context, you can have user records associated with this context. In this case, you have Myapp.Account.Users defined in lib / myapp / account / users.ex. Your structure will be created here.

  • I think that you are here, it is that the context is called the same as your entries, and this causes some confusion. On line 9 of your Users context, you Myapp.Users.User , but this module is never defined.

+3
source share

All Articles