Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Problems on migrating from Ruby 1.8 to 1.9

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Problems on migrating from Ruby 1.8 to 1.9

Problems encountered on migration simfy codebase from ruby 1.8 to 1.9
Talk for @colognerb

Avatar for elitau

elitau

May 16, 2012
Tweet

More Decks by elitau

Other Decks in Programming

Transcript

  1. ENCODING • Each and every String needs an Encoding •

    # encoding: UTF-8 • http://stackoverflow.com/questions/3291017/how-can-i-avoid- putting-the-magic-encoding-comment-on-top-of-every-utf-8- file-in • https://github.com/m-ryan/magic_encoding • http://blog.grayproductions.net/articles/ ruby_19s_three_default_encodings
  2. LOAD PATHS • Ruby 1.9 removed “.” from load paths

    • It was deemed a "security" risk • File.expand_path(__FILE__) • require_relative • require './filename' • http://stackoverflow.com/questions/2900370/why-does- ruby-1-9-2-remove-from-load-path-and-whats-the-alternative
  3. YAML PARSING • Psych (the new ruby YAML parser) is

    stricter with syntax • Fix your YAMLs • Dirty fix: in config/boot.rb require 'yaml' YAML::ENGINE.yamler = 'syck' • http://stackoverflow.com/questions/4980877/rails-error- couldnt-parse-yaml
  4. PARSEDATE • Ruby 1.8 has a Parsedate module, gone in

    1.9 • use Date.parse instead • http://stackoverflow.com/questions/4724417/ruby-where-has- parsedate-gone-in-1-9
  5. CASE SYNTAX • Colons do not work in 1.9 anymore

    • when ‘foo’ : ‘bar’ • when :foo then :bar
  6. ARRAY.TO_S • ree-1.8.7-2011.03> [1,2,3].to_s => "123" • 1.9.3p125> [1,2,3].to_s =>

    "[1, 2, 3]" • Do not use implicit conversions • Better: [1,2,3].join(‘’)