“The problem with finding beginner friendly Rails resources seems to be a lot of refer back to older ways of doing things (generally speaking, but also the asset pipeline in particular) and a lot of them lead me down rabbit holes that I often can’t tell are worth burrowing into or not.”
This is understandable. The differences between erb templating and newer javascript build processes can be confusing as hell if you’re totally new to rails and web dev in general.
The main rails app that I develop started in rails 4.2, then 5.0, and now 7.0.4 so I avoided all of the javascript build stuff.
It’s old school erbs with jQuery, bootstrap, and a few other thingss and it works well, but there are some things to keep in mind.
If I were you I’d first go way back to basic web pages. In your layouts/application.erb file just link the css and javascripts manually and - this is important - add a check for whether you’re on dev, test, or prod. For dev/test you would link the files just like any other basic web page. For prod you would use "the rails way"of linking so the assets would need to be precompiled.
You’ll be able to tell because the link on dev would just be the normal or while the rails precompiled assets will be " (or whatever the latest compiled asset name is).
I absolutely loathe precompiling css and javascript when developing - I want to make a change and reload the page and see the changes immediately.
You could also just add a switch like “use_precompiled_assets = true/false” set somewhere (ENV variable or the environment files). That way you can switch between the precompiled and non just by switching the setting without having to restart the server.
There have been countless times where I’ve forgotten to precompile and I don’t see changes and it drove me nuts, that’s why I added the switch.
One other thing - the “out of the box” compiler for javascript (can’t remember the name) doesn’t play well with es 6 javascript (at least the one I was using in rails 4 and 5) but there’s a drop in replacement that work exactly the same.
One last thing, you definitely want to have precompiled assets in production.
The amount of time to load javascript and css the old school way vs precompiled can be more than expected (100s of ms). Also the size of those scripts are shrunk way down when precompiled. Basically it’s all due to caching, and you’ll need to set the “serve static assets” if you’re on Puma. For nginx it’s set differently.
Rails is awesome, but I’d start old school and avoid the esbuild/forman/whatever’s the newest latest and greatest thing until you know how it works.
I don’t even know how the yarn esbuild etc. stuff works, and I don’t want to - old school is the way to go : )
Good luck.