My preferred text editor for Ruby on Rails development is Sublime Text 2, but I keep hearing great things about RubyMine. In advance of the release of the 2nd edition of the Ruby on Rails Tutorial book, last year I released a short Sublime Text 2 for Rails screencast; I’m pleased to announce that Justin Gordon (@railsonmaui) has produced a companion RubyMine tips screencast that does a great job of showing off what RubyMine can do, especially in the context of a Ruby on Rails application. I encourage everyone with an interest in using an IDE for Rails development to check out Justin’s screencast.
Rails Tutorial for Rails 4.0 RC1
After some initial hiccups, I’ve finished preparing a version of the Ruby on Rails Tutorial compatible with the first Rails 4.0 release candidate. Interested readers can take a look at it and let me know if anything doesn’t work.
Rails 4.0 Release Candidate 1
Update: Steve Klabnik has solved the problem discussed in the post below by noting that the latest version of the rspec-rails gem (2.13.1) has fixes specific to Rails 4.0. After upgrading the Gemfile to use this version, I have confirmed that the issue described in the post is fixed. Thanks, Steve!
The first Rails 4.0 release candidate, Rails 4.0 RC1, is now available. Unfortunately, although the Rails Tutorial sample app appears to run fine under the RC, a large number of tests fail. Most of the failing tests appear to be related to the test database not being rolled back properly. I’m posting the details here both to solicit assistance and to serve as a reference for the issue I’ve filed on the Rails issue tracker at GitHub. This issue is currently the main obstacle blocking the preparation of the Rails 4.0–compatible version of the Ruby on Rails Tutorial book.
Isolating the issue
To isolate the issue, I’ve prepared a minimial failing app. To reproduce the error I’m seeing, first clone it from GitHub:
1
| |
Then install the gems and migrate the database:
1 2 3 4 5 | |
Preparing the test database
So far, so good. The first problem comes from trying to run the tests after preparing the test database:
1 2 | |
Unfortunately, this doesn’t work. Instead, I get an error:
1 2 3 4 | |
I have never had to run rake db:migrate RAILS_ENV=test in the course of normal Rails application development. To my knowledge, this should automatically be handled by
1
| |
But to proceed I had to run it:
1
| |
Passing test, then failing test
The test now passes:
1 2 3 4 5 | |
Unfortunately, running the test a second time produces an error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Email uniqueness
If you look at the source code, you’ll see that the “app” is really just a User model that enforces email uniqueness:
1 2 3 4 | |
The corrsponding test just tries to save the user:
1 2 3 4 5 6 7 8 9 | |
After excuting the test, Rails should roll back the test database, but instead it is persisting from invocation to invocation, resulting in a violation of the email uniqueness constraint the second time through.
Reproducing the error
We can reproduce the error by removing the test database, re-migrating, and running the test again (twice):
1 2 3 4 5 | |
Any help in solving this issue would be much appreciated (admin at railstutorial dot org).
Rails Tutorial Russian translation
Hot on the heels of the Chinese version, I’m pleased to announce the availability of a Russian translation of the Ruby on Rails Tutorial. I’d like to thank translator Alexey Razuvaev (Алексей Разуваев) for his initiative and outstanding work. As with the English version, the Russian translation is available for free online as HTML. If you are a Russian speaker, please check it out!
The Ruby on Rails Tutorial for Rails 4.0 (beta)
tl;dr: A Rails 4.0–compatible version of the Ruby on Rails Tutorial book is now available online. Sales of the ebook and a supplementary screencast will start after the final version of Rails 4.0 is released (available at a large discount to current customers). A new third edition is planned for later this year (with upgrade discounts for current customers). Subscribe to get email notifications of future announcements.
I’m pleased to announce the availability of a full draft of the Ruby on Rails Tutorial book updated for Rails 4.0. Changes include updates to all relevant gems, the use of some newer features of Capybara, new-style scopes, updated Active Record finders, and coverage of the new strong parameters feature to prevent mass assignment vulnerabilities. Previous versions have benefited tremendously from the book’s many eagle-eyed readers, so please email me with any typos or bugs you find in the new version.
Warning: Rails 4.0 is currently in beta, and this is bleeding-edge stuff, so you may get cut. For example, as of this writing Spork doesn’t work with Rails 4. To work around this, the Gemfile in the book pulls directly from a fork I made of a repository that fixes the issue (and whose pull request hasn’t yet been accepted). Another example, needed to work around changes in Capybara, is to pull the XPath and Capybara libraries directly from the latest master branches on GitHub, which introduces a significant risk of instability. And there are surely other examples ready to surprise the unwary.
Once the situation has stabilized a bit, I plan to make a short supplementary screencast highlighting the relevant changes and showing how the sample app works with Rails 4. When that happens, I will make sales of the Rails 4 version ebooks (PDF/EPUB/MOBI) available as well.
Once I feel the changes in Rails justify the effort, I plan to release a complete revision with a new screencast series. That will involve some more extensive changes, including the incorporation of a new spec syntax supported by the latest version of RSpec (so-called feature specs). I expect this to happen some time later this year.
To get future announcements delivered to your inbox, subscribe to get email notifications. (Google apparently doesn’t believe in RSS, but I do, so you can also subscribe to the news feed.)
Rails Tutorial Chinese translation
I’m pleased to announce the availability of a Chinese translation of the Ruby on Rails Tutorial. I’d like to thank translator Andor Chen for his outstanding work. I deserve none of the credit; Andor reached out to me and asked if it was OK to translate the book, and I happily agreed. (All I did was contribute a short preface.) As with the English version, the Chinese translation is available for free online as HTML; with my blessing, Andor is also offering ebook sales of the translation, the proceeds of which go directly to him. If you are a Chinese speaker, please check it out!
Rails Tutorial News test post
This post is a test of the Rails Tutorial News feed. (This is only a test.) Since the Rails Tutorial News feed is (or, rather, was) hosted at Posterous, which is shutting down, I’ve moved it over to a new location. This post is written in Markdown, and the site is produced with Jekyll and Octopress. The generated static site is hosted at GitHub Pages.
I’m making this test post to make sure everything is working. If all goes well, the post will show up in your feed reader or email inbox (depending on your subscription preferences). Because of the new XML feed generated by Jekyll, it’s also likely that many feed readers will show sixteen or so unread posts. I apologize in advance for the noise; unfortunately, this is the inevitable cost of the changeover. This post is the only one that’s actually new, so you can just mark all the other posts as read.
Now back to our regularly scheduled program.
Rails security fixes, version upgrade
I’ve just upgraded the Ruby on Rails Tutorial to use Rails 3.2.11, which contains two important security fixes (one for SQL injection and one for parameter parsing). The latest versions of the online book, ebooks, and sample application all now reflect this change.
It is critical to upgrade all of your production applications as soon as possible. The easiest way to do this is to edit your Gemfile and change the Rails gem version from ‘3.2.x’ to ‘3.2.11’. Then run
$ bundle update rails && bundle install
to apply the update. (If you’re running Rails 3.1.x, 3.0.x, or 2.3.x, there are security patches for those branches as well, as detailed in the parameter parsing post.)
Programmer training academies
Programmers in general, and Rails developers in particular, continue to be in strong demand, and several excellent in-person training courses have sprung up to help meet the need, including Dev Bootcamp and App Academy in San Francisco, The Starter League (formerly Code Academy) in Chicago, and Hacker School in New York. (I’m pleased to note that all four have used the Ruby on Rails Tutorial as part of their curriculum at one time or another.) Such programs typically aren’t cheap (although Hacker School is free), but the people I’ve talked to who have gone through them say they are a good investment.
Dev Bootcamp doesn’t appear to have any openings right now, but both App Academy and The Starter League have openings for their classes starting on January 7, and Hacker School is accepting applications for its winter batch until January 1. If you’re interested in taking your web development skills to the next level, I recommend checking them out. (Note: While I have no formal relationship with any of the groups mentioned, I know people at all four places, and App Academy pays referral bonuses if you end up attending.)
Update on the Rails Tutorial print edition
tl;dr:
- Buy the print edition of the Ruby on Rails Tutorial, 2nd Edition
at Amazon.com
- Please leave a review at Amazon
- If you want a Kindle version, buy directly from railstutorial.org
This is a quick update on the print edition of the Ruby on Rails Tutorial, 2nd Edition. I’ve been notified by several readers that, despite the discount I negotiated at a non-Amazon retailer, in fact the print edition of the book is cheapest at Amazon. Having spent a week trying and failing to negotiate a bigger discount, I’ve decided that sending people to Amazon is best. (Please accept my apologies if you bought a copy at the (slightly) higher price; send me an email and I’ll do my best to make it up to you.)
This change in retailer also affords us an opportunity, as the book’s star rating at Amazon is currently being dragged down by several obsolete one-star reviews dating from the book’s blown first printing. Now that the corrected second printing is out, I would deeply appreciate it if you could leave a review at Amazon.com to help counterbalance these outdated bad reviews. (Of course, maybe you think the book deserves its one-star ratings, in which case—ouch.)
Finally, I’d like to note that the Rails Tutorial ebook bundle includes a MOBI format for Kindle. I’ve had reports that the formatting is nicer than the “official” version at Amazon, and my version comes with free updates and bugfixes, so I recommend buying directly from railstutorial.org.