#model0 is undefined or private

20 messages · Page 1 of 1 (latest)

upbeat nexus
#

I'm trying to add a model which contains fields for a form for people to message me, however I'm coming across an issue where my test is saying it is undefined or private.
What's most strange is that my LSP isn't catching the error at all.

Any help is greatly appreciated 🙂

humble lotus
#

use PortfolioWeb, :model is what's causing the issue, check your PortfolioWeb module file, it probably doesn't contain such a function.

#

It's been a long time since Phoenix and ecto have used the term "model" is this a very old codebase?

upbeat nexus
#

I ended up adding it to the web.ex file, however, if you have a write up on what the recommended approach would be I'd be very grateful to read up on it

rigid bluff
#

Just use Ecto.Schema

upbeat nexus
rigid bluff
#

It’s not a good idea for your non-web module to reference web

#

…and model isn’t a thing

humble lotus
#

yeah I'd second that, just put that code into the schema file instead and leave it out of PortfolioWeb. And limit the imports to only what you actually need, importing Ecto itself seems a bit much

rigid bluff
#

Lots has changed

upbeat nexus
upbeat nexus
rigid bluff
#

Personally, I don’t learn as well with courses. I just read the docs

#

And build stuff

#

I like to start with just the language and build something.

humble lotus
upbeat nexus