Genie.jl
Genie.jl copied to clipboard
Issues with the controller example from the docs
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
The error:
ERROR: UndefVarError:
MessageController not defined
If I include the file directly, as in the commented code, everything works as expected.
I tested with Julia 1.9.4 and downgraded to Genie v5.21.2 and GenieFramework v1.26.4 and still does not work.
@MariusDrulea can you maybe share the whole app (on Github) so we can take a look at and try it out?
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:
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.