Chapter 6 of the Rails Tutorial, 2nd Edition is out ("Modeling users")

This is an update on the progress of the Ruby on Rails Tutorial, 2nd Edition. A draft of Chapter 6, "Modeling users", is now available. It covers the creation of a full User model, including secure passwords via the awesome has_secure_password method (new as of Rails 3.1). Various bugs in the first five chapters have also been fixed; thanks to all the readers who submitted reports. As before, please send any feedback to admin@railstutorial.org, and leave comments at Hacker News. To learn more about the Ruby on Rails Tutorial, 2nd Edition, see the original announcement.

Ruby on Rails Tutorial, second edition (updated for Rails 3.2)

Since launching the Ruby on Rails Tutorial in 2010, I've been gratified by how many people have used it to learn web development with Ruby on Rails. Some people thought I was crazy to make the whole book available for free online, but the many readers who bought the PDF and screencasts have shown that it wasn't so crazy after all. (And to those who have apologized to me for only using the free version: Dude, that's why it's there!) Thanks to everyone whose goodwill and support have made the Rails Tutorial project such a success.

Recently, many people have been asking when the tutorial will be updated for the latest version of Rails, and I'm pleased to announce the beta release of the second edition of the Ruby on Rails Tutorial book, fully updated for Rails 3.2 and Ruby 1.9. This initial release consists of the first five chapters, and each week I plan to release 1–2 additional chapters until the full book is out. Sign up for the Rails Tutorial News Feed to be notified when new chapters are ready.

New features

The second edition includes many new features:

  • Fully updated for Rails 3.2 and Ruby 1.9
  • Coverage of the new asset pipeline
  • Behavior-driven development (BDD) with Capybara and RSpec
  • An introduction to Cucumber for writing client-friendly tests
  • Syntactically Awesome Stylesheets with Sass
  • Better automated testing with Guard and Spork
  • Rolling your own authentication with has_secure_password

After people have had a chance to read it and give feedback, I'll roll up the result as a PDF and start production on the new screencasts. Sign up for the Rails Tutorial News Feed to be notified of new product releases.

Bug reports

One of the great things about publishing early and often is being able to fix errors reported by readers. The first edition of the Rails Tutorial benefited tremendously from the help of thousands of early adopters, and I'd love to have your help with the second edition as well. If you find bugs or typos in the new edition, please send a report by email to admin@railstutorial.org. (By the way, please don't report broken cross-references such as Section \ref{sec:name_of_the_section}; these will all be fixed by the time the book is done.)

FAQ

Q: Will the new edition of the Ruby on Rails Tutorial be free to previous purchasers of the PDF or screencasts?

A: The second edition PDF and screencasts will be a paid upgrade, but current customers will receive a significant discount on the new products. And, as always, the online version of the book will be free.

Q: When will the new PDF and screencasts be ready?

A: The new PDF should be ready in the next month or two, and I'm hoping to release the new screencasts in late winter or early spring, which means they'll be ready by fall for sure. ;-)

Q: I'd like to buy the Rails Tutorial PDF/screencast bundle and get started now. Can I get the new edition for free when it's ready?

A: Email me when the time comes and we'll work something out. I'm not sure about "free", but I can probably give you an extremely generous discount.

Q: What is the biggest difference in the new edition?

A: The biggest change in the new edition isn't the upgrade to Rails 3.2 or has_secure_password, it's the new (and much slicker) programming style for the RSpec code. The results are quite pretty, as you'll see starting in Chapter 5.

Q: The first edition of the book had 12 chapters. Why does the new edition only have 11?

A: The new edition was able to eliminate a lot of the old secure password material because of the awesome has_secure_password method added in Rails 3.1, allowing the User model material from Chapters 6 and 7 to be combined into a single chapter.

Q: Does the new edition cover CoffeeScript?

A: No. The first edition barely has any JavaScript, so there's little point in adding new material on CoffeeScript to the second edition. This may be a subject for future products, though.

Q: You've mentioned that PolyTeXnic, the markup system used to make the Rails Tutorial book, will eventually be released as an open-source project. When will it be ready?

A: I don't have a specific timeline for the release of PolyTeXnic, but I can tell you that my plans in this direction have become more ambitious, not less, so everyone interested in PolyTeXnic can rest assured that, once there is news, it will be good. (Sign up to be notified when there is some.)

Q: I've found a bug or typo. Where should I report it?

A: Please send all bug and typo reports to admin@railstutorial.org.

Q: Do you have any plans for future products?

A: I do. Sign up for the Rails Tutorial News Feed to be notified of future releases.

Q: Where's the new edition located again?

A: It's here: the second edition of the Ruby on Rails Tutorial book. Enjoy!

Model annotation

A helpful reader has noted that the annotate-models gem used by the Ruby on Rails Tutorial has disappeared from RubyGems. When you try to bundle install, you get this error:

Could not find gem 'annotate-models (= 1.0.4)'
in any of the gem sources listed in your Gemfile.

The solution is to use the annotate gem instead:

Gemfile

gem 'annotate', '2.4.0'

Then run

$ bundle install

as usual.

In order to reproduce the behavior of the annotate command provided by annotate-models, you should use bundle exec and pass the new annotate command the before option:

$ bundle exec annotate --position before

The Ruby on Rails Tutorial book has been updated accordingly.

Rails Tutorial & Rails 3.1

As part of the effort to keep the Ruby on Rails Tutorial up-to-date with the latest version of Rails, I am pleased to announce the availability of a special new chapter on Rails 3.1 (which is currently available as a release candidate). You can find the new Ruby on Rails 3.1 tutorial chapter online here.

The Rails Tutorial PDF has also been updated, and I have produced an accompanying Rails 3.1 screencast, which is now included with the purchase of the full screencast series or PDF/screencast bundle. (Everyone who already bought the PDF or screencast series should check their inboxes for a free update. The download pages have been updated as well, so you can also search for "Your Ruby on Rails Tutorial purchase" in your email client.)

A future edition of the Rails Tutorial book and screencast series will of course use Rails 3.1 (or its successor) from the start. Look for an announcement later this year.

Rails Tutorial book update

I've updated the Ruby on Rails Tutorial to use the latest version of Rails 3.0 (3.0.9 as of today) in preparation for the upcoming release of a short supplementary chapter (and screencast) on Rails 3.1. There are lots of miscellaneous changes in this update of the book, including new versions of RSpec, Spork, and RubyGems itself. To update your sample application, take a look at the sample app's updated Gemfile or the full sample app on GitHub.

Affiliate program quick clarification

I have a quick clarification regarding this post: you get a commission on any sale made within 60 days of a user clicking on your affiliate link, not within 60 days of this announcement. In particular, if someone clicks on your link and then clicks again ten days later, the clock gets reset, so any sale within 60 days of the second click will earn you a commission.

Rails Tutorial affiliate program

The Ruby on Rails Tutorial project has benefited from the enthusiastic recommendations of readers of the Ruby on Rails Tutorial book and viewers of the Rails Tutorial screencast series. I'm pleased to announce the introduction of an affiliate program to reward people for spreading the word about the Rails Tutorial book & screencasts.

To sign up as an affiliate, go to the Ruby on Rails Tutorial Affiliate Program page and follow the instructions there. After creating your account, you will get a custom affiliate link that sets a cookie on the user's browser and then redirects to the main Ruby on Rails Tutorial page. If the user makes a purchase within 60 days of clicking the link, you will receive a 50% commission on the sale of any combination of Rails Tutorial products.

This project owes much of its success to good word-of-mouth from people like you. Thanks again for your enthusiastic support of the Ruby on Rails Tutorial!

Rails 3.0.7

Rails 3.0.7 has been released, and the Ruby on Rails Tutorial has been updated accordingly. To upgrade an existing application, edit your Gemfile and change the Rails gem version from '3.0.6' to '3.0.7'. Then run

$ bundle update rails && bundle install

If you use the Spork gem, I also suggest editing your Gemfile to upgrade from '0.9.0.rc4' to '0.9.0.rc5'.

Ruby Hero Awards

Nominations are open for the Ruby Hero Awards:

[Ruby Heroes] create educational content, develop plugins & gems, contribute to open source projects, and even put on events which help educate and make our lives as developers easier… Ruby Heroes was created to show some gratitude and give these people the recognition they deserve.

Ruby Heroes is not a popularity contest—as far as I know, the number of nominations doesn't affect who is selected as a Ruby Hero—but having lots of nominations surely can't hurt. I've nominated RSpec lead developer Dave Chelimsky (via his GitHub username, dchelimsky), and if you use RSpec I encourage you to do the same.

In addition, while it would be a bit gauche for me to nominate myself, I'm not above soliciting nominations, so if any readers/viewers of the Ruby on Rails Tutorial would like to nominate me, I would be honored. (My GitHub username is mhartl.) I was nominated last year and didn't win, but that was before the release of the free online Ruby on Rails tutorial book, so this year the results might be different.

Free bonus screencast on Haml

As a free bonus to buyers of the print edition of the Ruby on Rails 3 Tutorial (as well as to anyone who buys any products directly from the Rails Tutorial website), I have made a special informal screencast on Haml, an awesome templating language that is a drop-in replacement for Embedded Ruby. The video runs nearly an hour and covers most of the basics of Haml, including installation, syntax, and even some gotchas.

Purchasers of the print edition should enter their contact information at the bonus screencast page, together with a piece of information whose answer appears in the book. Purchasers of the PDF or screencasts should check their email for a special message or check their original download page for a special link.

I hope you enjoy this bonus screencast!

About

This is the news feed for Ruby on Rails Tutorial by Michael Hartl, the best place to learn Rails. Visit the main website for more information about the project. You should subscribe to the news feed and follow Rails Tutorial on Twitter for all the latest updates.

Subscribe via RSS »