Replies: 1 comment
-
|
Hey! 👋 Thanks for the thoughtful proposal. I totally see where you’re coming from, especially with a Rails background. That said, applications in Marten are a core design choice and not meant to be optional. The framework intentionally encourages splitting code into apps to enforce clear boundaries and avoid “catch-all” structures as projects grow (similar to Django). While using only the main app is possible for very small projects, it’s more of a convenience than a recommended structure. Introducing a flat mode (no apps, no prefixes, etc.) would go against this philosophy and add complexity by supporting two different project organization modes. More broadly, Marten is not meant to be a clone of Rails or to specifically accommodate Rails conventions. While it takes inspiration from frameworks like Ruby on Rails and Django, it ultimately follows its own principles and design decisions. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
Coming from a Rails background, the Marten app system feels restrictive for small to medium projects. In our production project (subscriptions, donations, e-commerce, admin dashboard), we ended up with:
auth/— logical, isolated domainabonnements/— became a catch-all (subscriptions, donations, orders, cart, shop, signup)admin/— back-officeThe
abonnementsapp grew organically and would benefit from being split, but adding more apps means more boilerplate (app.cr files, migration dependencies, template nesting).Proposal: allow flat project structure without apps
Rails doesn't require apps — models, controllers, and views live directly in the project. Marten already has a
MainConfig(label `main`) for the root `src/` directory. The remaining friction is:1. Table name prefix
Currently, models in `src/` get `main_` prefix (`main_user`, `main_order`). For the main app, no prefix would be more natural:
```crystal
Current: main_user
Desired: user (or configurable)
```
Suggestion: `MainConfig` should default to an empty prefix. Or allow per-app prefix configuration:
```crystal
class App < Marten::App
label :my_app
db_table_prefix "" # no prefix
end
```
2. Migrations in src/migrations/
Models in `src/` should have their migrations in `src/migrations/` (already supported via `MainConfig`).
3. Templates in src/templates/
This already works — `src/templates/` is a default template directory.
Rails → Marten comparison
Impact
This would be a non-breaking change:
Questions
Beta Was this translation helpful? Give feedback.
All reactions