Agile Web Development with Rails 7 Update
With Rails 7 shipping yesterday, it is time for an update on Agile Web Development With Rails.
I don't have a firm date yet, but expect to ship a beta in January. A beta means that you get eBook formats that are substantially technically complete, but haven't gone through the full editor/pagination/indexing/etc. process. Errata will be accepted during this process, and you will get periodic updates to the book as the errata are addressed and the book progresses through the publishing process.
I've been keeping up with Rails through the alpha/release candidates/release, and done all the major changes to the book. There remain are a number of chapters remaining that only need minor updating (generally covering server functions), and I may over time chose to add or remove items from the last chapter, where I talk about venturing past the defaults that Rails provides. Mostly what I am waiting for a time slot for release, which requires lining up people resources which is a difficult task given the twin problems on holiday schedules and unpredictable Rails release schedules.
What I can say is that modulo the final chapter, the book will cover the same material as previous editions, but looks to be a full chapter (and possibly more) shorter than the previous version. A number of examples of the changes:
The biggest is the replacement of webpack/React with Stimulus (and behind the scenes at this point, import maps). Gone will be pages of introduction to webpack and and overview of React and pages after pages of React code, and in their place will be three HTML templates, and one small Stimulus class.
The next biggest change is the introduction of Tailwind, eliminating much CSS. There are other CSS frameworks that could have eliminated much of the CSS that was present in prior editions of the book, but with the current release of Rails, those would have required node and bundling. I'm trying to keep close to the defaults. And, for completeness, there are some frameworks that would improved the visual appearance of the default scaffolding, but would not have materially decreased the amount of CSS required for this application.
What was previously the AJAX chapter is now focused on HotWire and Turbo. This chapter has been "HTML over the Wire" for many editions, facilitated by the following two line template:
cart = document.getElementById("cart") cart.innerHTML = "<%= j render(@cart) %>"
Now this template is replaced by calls to
format.turbo_streamwith both an inline and template example. The use of ActionCable/WebSockets has also been updated to use
Prior editions of the book suggested a much greater use of partials than what is initially provided by scaffolding. Now Rails scaffolding provides a much better set of partials to build upon. I get to remove both rationale and, in some cases, code.
I'm very pleased with the results. The book will show you how you can largely stay with Rails defaults and can build an application that is roughly 50% HTML, 40% Ruby, 5% CSS, and 5% JS. The resulting application will have the look and feel of a single page web application complete with asynchronous updates. The one deviation from the defaults - namely Tailwind - is readily and obviously one that you could chose to omit.
As for the last chapter, I'm thinking of adding an example usage of Lit, as web components are a good fit with import maps.
I personally hope that future releases of Rails pushes the potential for import maps further. I'd like to see more CSS frameworks without bundling, trancoding of languages like TypeScript and JSX, and either the ability to run import maps and bundlers side-by-side, or the ability to easily migrate from one to the other. But those are wishes for another day; for now, I'm rooting for import maps with pure JS and straight CSS, possibly augmented either by Simple CSS or Tailwinds.