JavaScript for Rails Developers
Make JavaScript your second-favorite language
by Rails DesignerFor decades Ruby on Rails devs have shrugged at JavaScript, cursed at it or vowed to never use it again. But over the years, JavaScript has improved greatly. And if you want to write modern (SaaS) web apps today, there is almost no way around it.
Sure, the Hotwire tools help you tremendously to write as little JavaScript as possible, but if you want something a bit more bespoke, you need to write some JavaScript (preferably using Stimulus) by hand.
This short and focused book will help you, Ruby on Rails developer, become more comfortable writing your own JavaScript and understand the JavaScript written by others. It won't be about React or Vue (or any of the other thousands available JS frameworks), but about writing and understanding JavaScript in the Hotwire-way.
The idea is to go from zero to a functional code editor in your Rails app throughout various, easy to digest chapters. This will cover everything from working with a dependency in Stimulus, to extracting logic in smaller classes, refactoring to be more readable and using more advanced features like promises and integrating websockets (using Action Cable).
If you have been a Rails developer who has cursed at JavaScript, this book might be for you. If you've been a Rails developer avoiding JavaScript at all costs, this book is what you need. For Rails developers who've wished JavaScript would just disappear, this book might change your mind.
Table of Contents
This is the tentative table of contents. Let me know if you want to see a specific subject.
- Introduction: about this book
- Getting Set Up
- Basic CodeMirror Integration with Stimulus
- Enhancing the Editor Experience
- Advanced Editor Configuration
- Real-time Collaboration
- Performance Optimization
- Creating Custom Extensions
- Testing and Debugging
- Case Studies and Recipes
The book also comes packaged with the complete and functional codebase for the editor, a markdown editor with live preview, code snippets, and a PDF cheat sheet on JavaScript for Rails developers.
FAQ
When will the book be published?
At this point there is the outline and multiple chapters written (I've redone it a few times). Aiming for early April 2025.
Is the book for beginners?
Yes, and no. If you are a Rails veteran but always steered away from JavaScript, this book might just be for you. If you are just starting out with Rails, I would recommend to focus on Ruby (and Rails) first, and then come back to buy this book.
Is this book about adding CodeMirror to a Rails app?
No. It uses CodeMirror as the foundation to add a code-eidtor in a Rails app to explain and teach modern JavaScript. It does not go into detail on the many features of CodeMirror.
Anything I can read or preview?
Nothing from the book yet (except the intro), but if you are curious about my writing around JavaScript and front-end code, check out these articles from Rails Designer.
How will the book be published?
Plan to provide digital distribution through popular formats like PDF and EPUB.
Is there bulk/team pricing?
Yes, if you want to read the book twice as fast, you can buy two copies. 😅 Or want to buy copies for your whole team? Reach out for a volume discount code (starting at 5 copies).