Trying to learn how to build an API with Phoenix v1.3
following this tutorial: https://dreamconception.com/tech/phoenix-full-fledged-api-in-five-minutes (made sure to follow each step to the letter)
When I attempt to run
I get the following 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
(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
This is the code: https://github.com/nelsonic/phoenix-api-example
Any help debugging it would be much appreciated.
The error indicates where to look at
line 65 of file lib/myapp/users/users.ex
That seems already strange not to use user.ex for the name of file.
Please show us the file, it might be a typo
Hi @kokolegorille thanks for quick reply. all the code is on GitHub.
the specific file you are requesting is: https://github.com/nelsonic/phoenix-api-example/blob/master/lib/myapp/users/users.ex
users.ex file was auto-generated not named by me.
Do you actually have a
Myapp.Users.User struct somewhere? The thing you linked just defined a
Myapp.Users module, and no structs.
There is a typo in the generated code
defmodule Myapp.Users do
The boundary for the Users system.
import Ecto.Query, warn: false
It should be defmodule Myapp.Users.User
try changing this, maybe
my bet is You made a typo when typing this
mix coherence.install --full-confirmable --model=“Users.User users”
when following tuto
I copy-pasted all the commands form the tutorial. didn’t
type anything, so if anything there might be a typo in the original post …
I attempted to change
defmodule Myapp.Users do to
defmodule Myapp.Users.User the error is unchanged.
Since the tutorial is using development branches this was bound to happen. I’ve corrected the tutorial and created a repo for the source code on Github: https://github.com/danschultzer/phoenix_ex_oauth2_provider_demo