
Modular Rails was finally released on Thursday last week. It was a very interesting experience for me to publish my first book and I want to share with you the whole story. How and when I started the book, what problems I encountered and much more. This is a long post so you might want to save it for later ;)
The story behind Modular Rails started over a year ago, in 2013.
FYI, Samurails was the name of Devblast before I decided to re-write it from scratch and rebrand it ;)
The Idea
If you’ve read Modular Rails, you know that I started working on modular applications around two years ago. A year later, I started to research about alternative and passive income that could complete my full-time job salary. I ended up on Nathan Barry’s website. I think he had just published one of his books and he was sharing how much his book had been a life changer. I was pretty impressed and super interested.
People were eager to learn what Nathan had to teach, the stuff that he learned while he was working as a designer. So I thought if he could do it, maybe I could too. Easier said than done.
I started to think about different topics for a book like learning Ruby on Rails (useless trying to top The Rails Tutorial). But then, I realized there was one thing that I was doing everyday that wasn’t really available anywhere on the Internet: modular applications. When I created my first modular application, I spent hours reading code from different projects, learning how Rails engines worked, how to build gems and so on. So maybe I could share it and people would want to learn it!
I didn’t have much to lose anyway. In the worst case scenario, I would end up having wasted my time and that’s it.
Lazy is good
But I didn’t start. I never got to actually work on the book even after having defined the plan and what I would be talking about. I just let it rot. For almost a year, I didn’t do anything. I even stopped posting stuff on my website. At that time, it was still named thibaultdenizet.com
. I think it was around November 2013. I just focused on other stuff for a while.
Fast Forward 6 months
Samurails
When I had spent enough time slacking, I decided to checkout my blog and see if it was getting some traffic. I was really surprised to discover that I was getting around 200 people per day. I was even more surprised to find my series of articles about Single Table Inheritance ranking at the first spot on Google!
Maybe I should write more articles and tutorials since people seemed to like them. The problem was that I didn’t really like the layout of the site and I didn’t want to use my name as the domain name anymore. The blog wasn’t about me, it was about Ruby on Rails. I remembered one of my friends who mentioned to me the name Samurails a few years back. I asked him if he was using it and if I could use it for my website. He agreed and I quickly bought the domain name and setup a 301 redirection from thibaultdenizet.com
.
The style still had to change. I didn’t like it. What I like is the orange color. It’s actually my favorite color! I had to use it on Samurails. I was totally in the Flat UI thing at that time so I found a nice Wordpress theme from Colorlib and set it up. The last step was to find a nice logo. So I started to look for some images on BigStock photo and found this awesome artist who was making amazing icons. I found some cool looking samurai head, changed a few things and I ended up with the current logo:
I also rebranded my tutorials and called them jutsus to match the name of the website. I wrote a few more jutsus before the idea of writing a book came back to my mind…
Authority
I went to Nathan Barry’s website again and see what he was up to. I found out he wrote another book: Authority, a book that shows you how to self-publish your own book. I instantly bought it and started to read it. It’s less than 200 pages but it’s packed with invaluable information. I loved it and finished it super fast. There are some success stories included in the book that will give you a motivation boost too!
This was around September 2014.
The Name
I was looking for a name but couldn’t find something awesome so I settled on ‘Building Modular Applications with Ruby on Rails’. Jeez. That’s an annoyingly long name but whatever: it delivers the message. Now that I had a name, I was ready to setup a landing page to start collecting emails from interested people.
Create a website for the book
I created a sub domain and put a simple HTML page with some Bootstrap style. Got a Mailchimp account and started collecting email addresses. I had a lot of work in my full-time job at that time and I didn’t want to start working on the book if nobody wanted to buy it. So I waited around two months before starting to write the book and I was able to collect some email addresses during that time.
Start writing
In November 2014, the time had come! I redefined the plan for the book and started to write the first two chapters: The Modular Way and Modular Rails. At that time, they were named Introduction to Modularity and Modularity with Ruby on Rails (I did a lot of renaming right before the book was published). These two chapters came quite easily. There wasn’t much code to show and the chapters were quite short.
Stop writing
After writing the first two chapters, I didn’t do anything for a month. Then December went by. I went back to France for Christmas and didn’t work on the book at all.
No more slacking, fix a release date
It was around mid-January when I decided that I had to stop lying to myself. I would never finish the damn book unless I work on it everyday and commit to it in front of everyone who was waiting for it. I created a page on Samurails where people could see the progression of the book and see what I was doing everyday. I committed to work at least 2 hours per day. But that still wasn’t enough to ensure that I will ever finish it. I know myself and I’m a professional procrastinator. So I set a release date. And a short one because people have been waiting for the book long enough! Once again, this was mid-January and I fixed the release date on February 26.
I had a lot to do.
Work my ass off
For the following month, I spent most of my evenings and at least a full day each week-end (I still needed to have a lazy day to reboot) working on Building Modular Applications with Ruby on Rails
. I hated the name. Anyway, I started to work on chapter 3 (which is now 4). First, I built SamuraiCRM and kept notes of everything that I was doing. I also committed the source code very often. Then I took my notes and structured the chapter 3. It took me a while to put all the source code, step by step, together. Then I had to test all the steps one after the other to be sure that everything was working correctly. The last step was to add some explanation before and after each piece of code. I repeated the same process to write the chapters 4 and 5. After that I had to retest everything from chapter 3 to chapter 5. That was very annoying to do but essential to be sure that the steps and the flow were error-free. The last chapter was easier to write since it’s a lot of theory with just a bit of practice.
The first draft of the book was ready 2 weeks before the release. But I still had so much to do!
Formatting & Editing
The fun part started after finishing writing the book. I wrote it using Sublime Text with the great MarkdownEditing package. I love using Sublime Text to code and it’s great to be able to use it to do my writing too. I first wrote my book as a collection of markdown files:
- 00_intro.md
- 01_introduction_to_modularity.md
- 02_rails_and_modularity.md
- …
Since I wanted to be able to share it easily with some of my friends, I decided to use Google Doc. I took each chapter, paste it in the Wordpress backend of Samurails and got the HTML result with Samurails style. Then I just had to copy each blog post generated from Samurails to Google Doc. Each chapter got its own file because Google Doc cannot really handle huge documents. Get over 30 pages and it will start lagging like crazy.
Once each chapter was is in its own Google Doc, I started to ask some of my friends to review the book. I also read it entirely, changed a few things and retested all the code. I also did a lot of editing and formatting and improved the look of the source code in the book by putting each code example inside a 1x1 table. The release was approaching and the book was almost done. I only planned to provide the book as a PDF at that time and the PDF generated by Google Doc looked good. Getting that PDF was quite hard. However, after merging all the chapters into one Google Doc, it was super slow. Exporting as a PDF only worked 1 out of 10 times so it was a pretty annoying process to download it.
The nightmare starts!
Then, the shit hit the fan! I was playing with my Google Doc PDF when I realized that copying and pasting the code samples was breaking the layout and removing all the spaces. Holy cow. Time to try some other exportable format available on Google Doc.
After trying the PDF, I tried the docx
file. I opened it with Pages and I thought it looked alright. I could export to PDF: the copy/pasting wasn’t perfect but I could live with it. The problem was the table of contents. It had no links to each section! It’s apparently a bug in the last version of Pages… Great!
How about OpenOffice files? I gave it a try. Nope, nothing good came out. When exporting to PDF, the result was not what I wanted.
I’ve always hated regular word processor like Word, OpenOffice and Pages. I like Google Doc for the sharing capabilities but I’ve learned my lesson. I don’t recommend using any of those tools to write a programming book.
I was getting a bit desperate. I had 2 days left before the release. I was sleep deprived and ready to give up and delay the release. I was ready to do anything, even switch back to markdown and redo all the formatting. So I checked out Pandoc once again but I was too stressed to dig in the documentation and spend hours understanding how to get what I wanted.
Maybe Leanpub or Gitbook could be my savior. I tried both but wasn’t convinced at all. I don’t like the idea of not having complete control and not knowing what is going on. I couldn’t even find how to change the style of the generated files!
I was hitting the bottom of desperation. Just trying out everything. Nothing was working. Since all the generated PDF sucked, I thought maybe I should provide other formats like EPUB or even a static HTML website… But how to do that?
The Solution
Then I remembered The Rails Tutorial. I checked how the book was written and I discovered the magnificent Softcover. An amazing gem that generates a book folder where you just have to write your book. I was so happy to find Softcover. I could write each chapter in its own markdown file and define the order inside some configuration file. Plus, there is a free ebook written by Michael Hartl himself that shows you how to use it. It shows you how to use Softcover, how to generate EPUB, MOBI and PDF and how to style them.
The best thing about Softcover is the way you write the book. First, you start a web server with softcover server
that gives you access to a HTML version of your book available at http://localhost:4000
. Now you can just go work in your markdown files and the website is automatically refreshed!
The only problem was that my original markdown files were outdated so I had to use the Google Doc content to create the new markdown files… and reformat everything! It took me hours to do it. I didn’t sleep much in order to have everything ready for the release date.
Softcover is also a publishing platform but I planned to use Gumroad from long time ago and already set up everything. So I used Softcover to generate PDF, EPUB and MOBI and style them. And then I realized you couldn’t share easily the HTML version. Indeed, the HTML version was meant to be push to Softcover and made available online. I didn’t want that. I wanted people to have a static website that they can access anytime and follow my book chapter by chapter. It was also much easier to copy source code from a web page than from the PDF.
To generate a static version, I simply used wget
. This little tool is just so powerful. I ran the Softcover server and wget
the entire thing with the following command:
wget -rkp -l6 -np -nH -N http://localhost:4000/
And that’s it! I had a good looking static website ready to be packaged. Finally, I was able to make everything in time. Plus, it was better than what I originally planned for since I had more formats: HTML, PDF, EPUB, MOBI.
Define packages
Writing the book is just the first part. Then you need to prepare the book for the release. Nathan Barry recommends to have different packages including other formats (video, case studies, …). It was really hard for me to find what I should add to the higher packages but finally I decided on the following:
- The Source Code
- Screencasts
- Case Study
- Interview
Fixing the prices was also a challenge. I find it very hard to assign a value to a knowledge that you already have. You really need to think about the value for someone who doesn’t know anything about what’s in your book. I ended up with the following prices: $39, $79 and $149.
Changing the name
A bit before all the troubles that you’ve read about above, I realized that I hated the name. Too long to type, couldn’t even fit it in a tweet with other details. So lame!
I had to rename it. And then I found it: Modular Rails. It was just so simple and such a great summary of what was the book about. I loved it, submitted to some of my friends and they loved it too. ‘Building Modular Applications with Ruby on Rails’ was killed.
Make the screencasts
Making the screencasts was hard. I didn’t have much time left but I wanted to include at least 5 screencasts. I made a list of different topics and picked the ones which provided the most value for the less effort (20/80!). I ended up having the following screencasts:
- The Modular Workflow
- Create a Private Gem Server
- Clean your Modules with Decent Exposure
- Configure your Models
- Create a Linking Module
I didn’t have much experience making screencasts (and I still don’t!) so I just did the way I felt was the best one. I wrote a list of the steps to follow in the videos and just use Quicktime to record my screen. The good thing with screencasts is that you can edit anything wrong. You can pause for 30s thinking about the best way to explain something and just cut it in the editing process. That’s awesome! I used iMovie to edit the screencasts. I really enjoyed making the screencasts for Modular Rails, it taught me a lot and I definitely want to produce more for Samurails!
Force friends to read the book
It’s important to have some feedback before you release a book. So I -forced- politely asked some of my friends to review the book and tell me what they thought about it. I also asked some quotes from them to put on the website.
Release the book
Finally, the time came to release the book. I wanted to release it at 9pm UTC +7 (Bangkok Time). Unfortunately, I couldn’t. Everything was ready but I forgot to take something into account.
The time to upload 5 screencasts to Gumroad. The screencasts were ready since the day before so I could have uploaded them. I just didn’t realized it would take me more than 2 hours to upload everything… The book was finally released around 11pm Bangkok time.
After pushing the updated website for the book, I shared it on Hacker News and Reddit. Then I sent a newsletter to the people who were waiting for the book!
The Result
I’m happy to stay that I sold more than one copy of Modular Rails! I was really surprised when I sold my first Complete Package. Thanks to everyone who bought Modular Rails and I hope you learned a lot with it ;)
Conclusion
Writing Modular Rails was a very enlightening experience. That’s why I’m already thinking about my next book. I actually have 3 different topics and each of them could become a very nice book. I just need to decide which one is the best and get started on it. But first, I want to work on Samurails. I want to provide more jutsus and start making screenjutsus!