-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Model method does not exist" solution can be improved #52
Comments
I am not sure to see what you mean. Could you post a code snippet so that I can reproduce the issue ? 🙏 |
The error seems clear to me and i'm not sure what you find confusing about it. I'll reopen and fix if you can provide a solution that makes sense to you |
Here's what I mean. This throws an exception, rather than rendering the home view: It's not about a calling a method on a model. It's about the fact that the model hasn't been persisted yet and attempting to access an attribute/property (not a method), will throw this error. If I change the above slightly to the following, the error isn't thrown. The email is returned: |
Ok so Ill add a possible solution like
|
How you are going to differentiate a normal class from a model class ? Because it should be a solution for Masonite Model classes only... 🤔 |
If the model is brand new, hasn't been created yet (
not model.is_created() == True
), then trying to access a property on the model likeif not user.picture: ...
will result in this error. The solution offered can be confusing.The text was updated successfully, but these errors were encountered: