Ruby on Rails Tutorial News

Full draft of the Rails Tutorial 3rd Ed.

Drafts of Chapters 9–12 from the Ruby on Rails Tutorial (3rd Ed.) are now available:

Chapters 9, 11, and 12 have been extensively revised for the 3rd edition, and Chapter 10 is completely new. With this release, the 3rd edition draft is now available in its entirety; see the main 3rd edition announcement post for more details, and sign up here for priority notifications and an exclusive coupon code.

I hope to launch ebooks sales of the 3rd edition within a few weeks. All current customers will get upgrade discounts, with especially generous discounts for those who made recent purchases.

Drafts of Chapters 5–8 from the Rails Tutorial 3rd Ed.

Drafts of Chapters 5–8 from the Ruby on Rails Tutorial (3rd Ed.) are now available:

All four of these chapters has been extensively revised, and the last has been almost completely rewritten. It now includes all three of the most common login models (temporary sessions, automatic persistent sessions, and optional persistent sessions with a “remember me” checkbox). See the main 3rd edition announcement post for more details, and sign up here for priority notifications and an exclusive coupon code.

Draft chapters of the Ruby on Rails Tutorial (3rd Ed.)

tl;dr: Draft chapters of the 3rd edition of the Ruby on Rails Tutorial are now available. I believe it’s the best edition yet. Sign up here for priority notifications and an exclusive coupon code.

In the past few years, the Ruby on Rails Tutorial book has become one of the leading introductions to web development. Both the 1st and 2nd editions have found broad audiences, and now I’m pleased to offer draft chapters of the 3rd edition, called Ruby on Rails Tutorial: Learn Web Development with Rails. For reasons detailed below, I believe it’s the best edition yet. A draft of the full manuscript is currently available:

The 3rd edition of the Ruby on Rails Tutorial will follow the same basic model as previous editions: a free online version, with ebooks and screencasts available for purchase. I also plan to produce a solutions manual for the book’s exercises, which will probably be included with one or more product bundles.

Perhaps the most surprising feature of the 3rd edition is that it is simultaneously easier and more advanced than previous editions. Whereas previous editions required readers to climb (sometimes unavoidable) brick walls, the 3rd edition is more like a ramp: smoothly increasing in difficulty, but ultimately reaching a greater height than before.

Here are the main factors that make the 3rd edition easier:

  1. Use of a standard integrated development environment in the cloud, with a pre-configured workspace specifically tailored to the needs of the Ruby on Rails Tutorial. Use of the custom Cloud9 IDE environment eliminates the installation and configuration overhead encountered in previous editions, while also providing the text editor, terminal window, and filesystem navigation necessary to complete the book’s three example applications.

  2. 100% default stack. The 3rd edition of the Ruby on Rails Tutorial uses the default Rails choices for all relevant technologies, thereby substantially reducing the configuration necessary to get started. The excellent but syntactically heavy RSpec testing framework has been replaced with the default Rails testing stack (MiniTest), making for a much gentler introduction to testing than in previous editions.

  3. Lighter-weight testing approach. The 3rd edition still covers test-driven development (TDD), but uses it more sparingly and judiciously. The more forbidding “wall of tests” sections have been eliminated, with concise and expressive integration tests (usually written after the application code) taking their place.

  4. Less emphasis on version-specific features. Rather than trying to incorporate mini-tutorials on new features for each version of Rails, the 3rd edition focuses on the most general principles of web development. This means that, although the tutorial does use the most recent Rails release, this fact is incidental, and it is not tightly coupled to the details of any particular version.

  5. Highlighted lines and red/green indicators. By making use of features of the underlying Softcover self-publishing platform, the 3rd edition of the Ruby on Rails Tutorial now includes highlighted lines in many code samples, allowing readers to see at a glance which parts of the code are most important. In addition, many code listings now include explicit labels indicating whether the test suite should be passing or failing at that point in the tutorial, thereby orienting the reader and making the exposition much easier to follow. (See Listing 3.12 for an example.)

Meanwhile, these are the main factors that make the 3rd edition more advanced:

  1. A completely rewritten chapter on login and authentication. The newly revised Chapter 8 covers all three of the most common login models on the Web: session expiration upon browser close, automatically remembering users, and optionally remembering users with a “remember me” checkbox.
  2. An all-new section on image upload. Chapter 11 now shows how to add pictures to the Twitter-style “microposts” developed in the tutorial’s main sample application. Topics include client- and server-side image validations, automatic image resizing, and using a cloud storage service (Amazon S3) in production.
  3. An all-new chapter on account activation and password resets, including sending email with Rails. The all-new Chapter 10 considerably extends the core sample application by adding account activation (thereby verifying the account’s email address) and allowing users to reset forgotten passwords. In the process, the chapter covers how to send email with Rails, both in development (using the server log) and in production (using SendGrid).

I’m more excited about the 3rd edition of the Ruby on Rails Tutorial than about any previous version. As reflected the new subtitle, Learn Web Development with Rails, I believe that the Ruby on Rails Tutorial constitutes not only a solid introduction to Rails, but also a thorough general introduction to web development. It wouldn’t be nearly as good as it is, though, without the contributions of hundreds (perhaps thousands) of readers who have taken the time to write in with bug & typo reports and other suggestions. As with previous editions, I thus look forward to getting feedback on the draft chapters of the 3rd edition of the Ruby on Rails Tutorial. And don’t forget to sign up here for priority notifications and an exclusive coupon code.

Softcover – A publishing platform based on the Rails Tutorial

When I published the first four chapters of the Ruby on Rails Tutorial in 2009, it represented an experiment: would it be possible to give away a book for free online while still making a successful product business? The answer, happily, turned out to be yes. I have been pleased at how many people have been able to use the free online version of the Ruby on Rails Tutorial book to learn web development. At the same time, right from the beginning sales of the Rails Tutorial ebooks and screencast videos have made it profitable as well. It’s been deeply gratifying to be able to play a role in lowering the financial barrier to acquiring such a valuable skill as web development while still building a sustainable business.

Now, I’m pleased to announce Softcover, a publishing platform based on the Rails Tutorial production system and business model. Using Softcover, authors can build multi-format ebooks (HTML, EPUB, MOBI, and PDF) from common source files, optionally bundle them with media like screencast videos, and publish them to Softcover’s integrated sales platform with a single command. Of course, Softcover also outputs an HTML version of each book—which, as with the Rails Tutorial, authors can (optionally) make available for free online.

To see what a full product on Softcover looks like, check out Conquering the Command Line, a book and screencast series on Linux and Unix commands by author Mark Bates, which (like the Rails Tutorial) includes a free online version. In addition, there is already a version of the Rails Tutorial book that builds on Softcover, and in the coming weeks I plan to move the full tutorial over to the Softcover platform (taking care to preserve things like legacy download links). Watch for an announcement once the change-over is complete.

My hope is that Softcover will help allow many other authors to replicate the success of the Ruby on Rails Tutorial. If you’re interested in using Softcover yourself, you can learn a little more about it on the Softcover home page. Then sign up for an account and follow the instructions on the start page.

Japanese translation of the Rails Tutorial

I’m pleased to announce the availability of a translation of the Ruby on Rails Tutorial to Japanese, the native language of Ruby creator Yukihiro “Matz” Matsumoto. I’ve had the pleasure of meeting Matz and several other Japanese Ruby developers over the years, and they’ve always impressed me both with their technical brilliance and their friendliness. I consider it a great honor that Yohei Yasukawa, Shozo Hatta, and their fellow contributors have chosen to translate the Rails Tutorial to Japanese, and I thank them for their excellent work.

As with the English version of the Rails Tutorial, the Japanese translation is available for free online as HTML; with my blessing, the Japanese translators are also offering ebook sales of the translation, the proceeds of which go to support their efforts. If you are a Japanese speaker, please check it out!

Rails Tutorial updated for Rails 4.0.1

I’ve just updated the Ruby on Rails Tutorial book for the newest Rails release, Rails 4.0.1. If you’re updating your sample_app to Rails 4.0.1, you’ll need to change rails to 4.0.1 and bcrypt-ruby to 3.1.2, as seen in the reference sample app Gemfile:

source ''
ruby '2.0.0'

gem 'rails', '4.0.1'
gem 'bootstrap-sass', ''
gem 'bcrypt-ruby', '3.1.2'

Then run

bundle install
bundle update
bundle install
rspec spec/

(I’m actually not sure if both calls to bundle install are necessary, but they can’t hurt.)

As far as I can tell, there are no changes between Rails 4.0.0 and 4.0.1 that affect the Rails Tutorial, but please let me know if you run into any issues.

Rails 4.0 ebooks and supplementary screencasts

tl;dr: Rails Tutorial products updated for Rails 4.0 are now available. Current customers should check their email for generous coupon codes; new customers can use the code rails4launch by Monday, July 22, to get a 25% launch discount.

I’ve just launched sales of two new products, motivated by the recent release of Rails 4.0. The first product is the Rails 4.0 version of the Ruby on Rails Tutorial book in the three most popular ebook formats (PDF/EPUB/MOBI) . As noted in a previous post, the 4.0 version is not a completely new edition, but it is 100% compatible with Rails 4.0 and covers a significant number of new features (now listed in Box 1.1 of the new version).

The second new product is a pair of supplementary screencasts on Rails 4.0 based on an all-new supplementary chapter that is part of an enhanced 2nd edition of the book. The supplementary screencasts include a live demo of upgrading the Rails Tutorial sample application from Rails 3.2 to Rails 4.0, a discussion of the new strong parameters technique for preventing mass assignment vulnerabilities, and two new security updates (dynamic secret tokens and encrypted remember tokens). Note that, in keeping with the tutorial’s principal goal of being a general introduction to web development, the new chapter and screencasts do not attempt to cover all the new features in Rails 4.0. For those interested in keeping up-to-date with the latest Rails techniques, I recommend RailsCasts.

As usual, the full text of the book is available for free online, including the Rails 4.0 version and the supplementary chapter.

To meet the needs of the largest number of customers, the new products are available in several ways:

  • The ebooks now include both the full Rails 4.0 version and the 2nd edition with the new supplementary chapter. Recommended for current ebook customers and new customers who don’t want screencasts

  • The ebook/screencast bundle now includes the enhanced 2nd edition book, the 4.0 version of the book, and the Rails 4.0 supplementary screencasts, as well as the full 1st and 2nd edition screencast series. Recommended for new customers who learn well from screencasts

  • A new supplement bundle combines the enhanced 2nd edition book, the 4.0 version of the book, and the Rails 4.0 supplementary screencasts. Recommended for current ebook/screencast customers

If you do decide to buy a Rails 4.0 product, be sure to use the code rails4launch by Monday, July 22, to get a 25% launch discount, unless you are current customer. Current Rails Tutorial customers should check their email to find coupon codes for special discounts on the new products. (You might notice that the prices have gone up with the addition of the new products; the discounts are large enough that current customers are still better off having bought things earlier rather than later.)

One more test post

The recent switch to Heroku ferreted out an annoying bug in the Rails Tutorial News Feed, namely, hard-coded GitHub Pages URLs deep in the site’s configuration. All the links on the site itself were fine, but the Atom feed had the obsolete GitHub Pages addresses. I’m glad to find out about this, as I certainly never meant to expose those URLs, preferring to use custom subdomains (e.g., whenever possible. So, the prophecy in my last post that this sort of issue wouldn’t soon happen again has gone unfulfilled, but I’m optimistic that this is indeed the last time.

I’ve changed over the feed to use the proper URLs, but it might take a few days for all the caches with the old feed to expire. Thanks for your patience, and sorry for all the noise.

Switching the news feed to Heroku

After having some trouble with the refresh times on GitHub Pages, a few days ago I switched the Rails Tutorial News Feed over to Heroku. Some of you may have noticed a large number of unread articles in your feed reader or email summary; this change from Pages to Heroku is the reason why, as it forced a regeneration of the site’s Atom feed. Now I’ve discovered that a few posts got lost in the transition; I’ve added them back, which means another chunk of “unread” items may show up in your reader or inbox. The Heroku site is now working well, though, so I’m optimistic that this kind of thing won’t happen again any time soon.

A more secure remember token

I recently received a helpful email from reader Yuri Krichevsky pointing out a way to improve the security of the “remember me” tokens used in the Ruby on Rails Tutorial book. Since I’m gearing up to release the Rails 4.0–compatible version, I decided to go ahead and implement the more secure method. The result appears starting in Section 8.2.1 of the new version, with the corresponding sample app code available on GitHub. I’ve edited it carefully, but there were a lot of little changes, so it’s possible some errors slipped through. If you get the chance, please take a look at it and let me know if it works as advertised.