-
Hi! For context, I've worked a lot with RoR in the past. Therefore the project/application structure is new to me. To understand it better I had a look how Django is handling this. They also have a good tutorial about apps. The whole concept looks quite nice to organize stuff. What I'm missing in Martens documentation is a how to work with apps. The documentation states that there are apps and how they are generated/structured, but now how to integrate them (beside adding them to So I created a website marten new project mysite Installed dependencies cd mysite/ && shards install Create an application in my project marten new app blog --dir=src/blog Added it to my project: # Create src/blog/models/article.cr
# Add `require "./blog/**"` to "src/project.cr"
# Add `BlogApp` to `config/base.cr` Generated migrations marten genmigration which returned Generating migrations for app 'blog':
› Creating [src/blog/migrations/202308030836021_create_blog_article_table.cr]... DONE
○ Create blog_article table And tried to migrate them, which resulted in In src/blog/migrations/202308030836021_create_blog_article_table.cr:3:43
3 | class Migration::Blog::V202308030836021 < Marten::Migration
^----------------
Error: undefined constant Marten::Migration Do you have some guidance what I'm doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey! 👋 Thanks for the feedback! Yes the Marten applications mechanism is definitely inspired by Django's. 🙂 Regarding the error you are encountering, I think there may be two reasons:
This should fix the issue you were encountering! The Finally, this mechanism is by no means perfect and it's on my todo list of things to improve in the framework. Ideally, we would benefit from having a generation command that is capable of adding a new application to the project automatically by creating the application files, but also adding it the list of installed applications, adding the associated requirements, etc. The Also happy to review PRs with ideas on how to make this behavior clearer or to discuss alternative ideas! |
Beta Was this translation helpful? Give feedback.
Hey! 👋
Thanks for the feedback! Yes the Marten applications mechanism is definitely inspired by Django's. 🙂
There is some documentation around applications and how to create them but I guess it's not visible enough or complete enough. I'll definitely look into that.
Regarding the error you are encountering, I think there may be two reasons:
./blog/**"
insrc/project.cr
should be changed to./blog/app
. The reason behind that is that CLI-related abstractions related (such as the migration ones, which are only used through the Marten CLI) are not required by Marten itself when you require Marten viarequire "marten"
. The automatically generatedblog/app.cr
file requires o…