Skip to content

docs: add Rails comparison guide for developers migrating to Marten#357

Open
papilip wants to merge 1 commit into
martenframework:mainfrom
papilip:docs/rails-migration-guide
Open

docs: add Rails comparison guide for developers migrating to Marten#357
papilip wants to merge 1 commit into
martenframework:mainfrom
papilip:docs/rails-migration-guide

Conversation

@papilip

@papilip papilip commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a comprehensive comparison guide for Ruby on Rails developers discovering Marten. Placed in docs/getting-started/rails-comparison.md.

Content

Side-by-side comparison covering:

  • Project structure (Rails flat vs Marten apps)
  • Models and field declarations
  • Queries (ActiveRecord vs Marten ORM)
  • Controllers → Handlers
  • Routes
  • Templates (ERB vs Marten Django-style)
  • Migrations (manual vs auto-generated)
  • Sessions and authentication
  • Email
  • CLI commands
  • Common gotchas for Rails developers

Motivation

Crystal attracts many Ruby developers. A clear mapping between Rails and Marten concepts lowers the learning curve significantly. This guide was written based on real-world experience building a production application with Marten.

Test plan

  • Markdown renders correctly
  • All code examples are syntactically correct
  • Gotchas section based on real bugs encountered in production

Comprehensive side-by-side comparison covering models, queries, handlers,
routes, templates, migrations, sessions, email, CLI, and common gotchas.
| Migrations | `rails generate migration` | `marten genmigrations` |
| Console | `rails console` | Crystal doesn't have a REPL |
| Package manager | Bundler (Gemfile) | Shards (shard.yml) |
| Test framework | RSpec / Minitest | Crystal spec |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to use with https://github.com/ysbaddaden/minitest.cr

@papilip papilip May 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer! After looking at this more closely, minitest.cr can't currently be used as a drop-in for Marten's test helpers: Marten::Spec registers its lifecycle (DB flush, client reset, collected emails) on Crystal Spec's before_suite / after_each hooks, while minitest.cr is a standalone runner with its own lifecycle — so DB and client state would leak between tests.

I've opened #360 to discuss decoupling the test lifecycle from Crystal Spec, which would make minitest.cr (and spectator, etc.) usable with Marten's helpers via thin adapters. Once that's resolved I'll happily update this row.

For now I'll keep Crystal spec as the documented option to avoid misleading readers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is true, but it is not hard to make it work: https://dev.to/miry/make-marten-web-framework-work-with-minitestcr-49kd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants