This post is part of a series of 31 Rails 4 articles being released each day in December 2012.
As of June 2013, Ruby 1.8.7 will no longer by maintained by the Ruby core team. It has reached its end of life and Rubyists have been asked to use Ruby 1.9 moving forward. In an announcement on the official Ruby site, Ruby committer Shyouhei wrote the following:
"I have been using 1.9 for years and now I cannot go back to the days without it. Rich features. Faster execution. Rubygems integrated. Rails works perfectly. I cannot but say it is totally wonderful. Everyone please, use 1.9."
As of Rails 4, a Ruby version of at least 1.9.3 will be required to run the framework. If by chance you are still running 1.8.7 in your Rails application, you should devote some time to upgrade to 1.9.3 today.
Ruby 1.9 Upgrade Tips
Here are a couple of changes to look out for while upgrading your applications:
String#to_ano longer exists. If you want to create an array from a string, you must wrap it in an array.
Array("Rails4") # => ["Rails4"]
Array#to_sis no longer an alias for
Array#to_sin Ruby 1.9 will result in a call to
- Strings in Ruby 1.9 are character based. Accessing a character via
String#will return a character and not an ASCII value.
"Rails" # => 'R'
Time.parsenow uses the format
The Ruby 1.9 Walkthrough
The absolute best resource for Ruby 1.9 is the Ruby 1.9 Walkthrough by Peter Cooper. Peter put together the most comprehensive guide to Ruby 1.9 available from the Ruby 1.8 perspective. The walkthrough clocks in at three hours.
For those of you interested in purchasing the Ruby 1.9 Walkthrough. Peter Cooper has graciously offered a discount code to our readers. Using the code YAY19, you can purchase the Ruby 1.9 Walkthrough for 60% off.
He has also made the first hour available for preview:
Like many other developers, Ruby 1.8 was my first version of Ruby. It will always have sentimental value, but it is time to put this old friend to rest.