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 more bespoke, you need to write JavaScript (powered by Stimulus) by hand.
This short and focused book (~35,000 words / ~7 hours of reading) will help you, Ruby on Rails developer, become more comfortable writing JavaScript that is as great-looking as your Ruby code and understand the JavaScript written by others. It won't cover React or Vue (or any of the other thousands available JS frameworks), but about writing and understanding JavaScript used in Stimulus controllers.
The book goes 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 (CodeMirror) in Stimulus, to extracting logic in smaller classes, refactoring to be more readable and using more advanced and modern syntax 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
Every chapter is divided in sections and sometimes subsections to dive deepter into a certain topic. Preview some of the chapters below.
-
Introduction
- About this book Preview
- History lesson: evolution of JavaScript
- Setting the stage
-
Basic CodeMirror Integration with Stimulus
- Creating a Stimulus controller for CodeMirror
- Initializing CodeMirror in the `connect()` lifecycle method Preview
- Retrieving and saving editor content
-
Enhancing the editor experience
- Beyond the basic setup
- Languages and auto-completion
- Syntax highlighting and themes
- Custom preferences
- Extending with custom features
- Adding snippets
-
Advanced editor configuration
- User customization through values API
- Internationalization (I18n) Preview
- Panels
- Split views
-
Real-time Collaboration
- Optional read-only
- User presence indicators
- Lock for new users
- Real-time updates
-
Debugging
- Fundamentals Preview
- Browser DevTools
- Monitoring performance
- Production monitoring
- Grab bag
- Reflection & resources
FAQ
In which formats is the book available?
The book is offered as PDF and ePub.
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 read this book.
Is this book about adding CodeMirror to a Rails app?
No. It uses CodeMirror as the foundation to add a code-editor in a Rails app to show how to write good-looking and modern JavaScript. It does not go into detail on the many features of CodeMirror.
What is included with the book?
Based on your tier, you get the editor built in this book ready-to-go, along with various code snippets. The 2nd tier includes variants of the code editor: a code playground (like Codepend) and a markdown editor with a live preview, next to that is an example for an embeddable JavaScript widget to chat with your app's users. Finally you get access to Rails Designers; a private community for Rails UI Engineers & Frontend Designers.
Is there bulk pricing?
Yes, reach out if you need 15 user licenses or more.
JavaScript for Rails Developers
Choose one of the three tiers below
Get your copy!
Professional
$
79
What is included?
- Full book (PDF/ePub)
- Full code-base access
- Code snippets
- Code repos for: Markdown Editor + Preview Variant, Code Playground & Embeddable widget JS
- Access to Rails Designers ($49 value), private community for Rails UI Engineers & Frontend Designers (launching Q3 2025)
Team (5 developers)
$
179
What is included?
- Full book (PDF/ePub)
- Full code-base access
- Share with 5 developers in your team