I already have many Rails projects, but today we are starting a new project and I would be happy to use Rails 7 directly.
It is an alpha version, but I’m pretty sure that within a few months when we release in production there will be a stable version of Rails 7.
My only concern is about the scaffold generated by rails new. What if there are some bugs in the Rails alpha and we end up with buggy code forever in our git repository?
Is there any way to make sure that when the final release of Rails 7 is out we can check all the generated files?
My only idea is to run rails app:update when the final release of Rails 7 is available… although it’s not really an update, since we are already on Rails 7. Is that the correct approach to fix any files that were wrong in the alpha?
I would not let the tail wag the dog like this. The scaffolding is a once in a lifetime feature, and once it runs, nothing (certainly not the rake app:update) will change it. Read up on what that task does, by the way. It’s very limited.
You can fix the scaffolding by copying the templates into your app, I believe at lib/tasks/templates, and editing them there. Remember, though, that will only affect new models that you scaffold after making these changes and additions. Nothing affects the files that are output by the scaffolding process after they have been created.
Here’s an easy way: when Rails 7.0 final comes out run the exact same rails new command you will use today, and let it overwrite all your existing files. You will notice that some files will be skipped because they are identical, some will be changed because they aren’t.
Then it’s just a matter of using diff to see what changed and fix as needed. I’ve been updating an app since 5.1, so I’ve done this a few times. Works fine.
https://railsdiff.org is a super helpful tool after v7 is released. I won’t update the config unless I have to until v7 is released.
Saves me a ton of work. Started a new project (rails 7) in august or September and not had a single issue that wasn’t already present on previous rails versions.