Skip to content
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

Issues with the controller example from the docs #697

Open
MariusDrulea opened this issue Jan 7, 2024 · 4 comments
Open

Issues with the controller example from the docs #697

MariusDrulea opened this issue Jan 7, 2024 · 4 comments
Assignees

Comments

@MariusDrulea
Copy link

MariusDrulea commented Jan 7, 2024

I'm having problems with the autoload of controllers, usage in the docs https://learn.genieframework.com/docs/guides/adding-dynamic-pages#pages-with-a-controller. So what am I doing wrong here?

system: Linux and Julia 1.10

image

The error:
ERROR: UndefVarError: MessageController not defined

If I include the file directly, as in the commented code, everything works as expected.

@MariusDrulea
Copy link
Author

I tested with Julia 1.9.4 and downgraded to Genie v5.21.2 and GenieFramework v1.26.4 and still does not work.

@essenciary
Copy link
Member

@MariusDrulea can you maybe share the whole app (on Github) so we can take a look at and try it out?

@PGimenez
Copy link
Member

PGimenez commented Jan 8, 2024

Apparently the context parameter is missing, the module loads after adding it:
Genie.Loader.autoload("controllers", context=Main.App)

However, there's another error in the controller code after that which I don't recall seeing before...

That guide was a quick way to introduce the MVC architecture, but now I'm seeing that perhaps it was not a good idea. I'll remove it from the docs.

If you want to use controllers or adopt MVC, I suggest you use Genie.Generator.newapp to create your app and build from there. We have two good long tutorials on this:

Books app

Movies app

@MariusDrulea
Copy link
Author

MariusDrulea commented Jan 8, 2024

hm... It works if you directly include the MessageController.jl file. If I have a lot of controllers and models and views, I would probably want to include each controller individually for the specific model and view. Not all at once. Not sure if this is relevant.

Going to try the .newapp functionality. Played a bit with the GenieBuilder, it's very cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants