Save 37% off PRO during our Black Friday Sale! »

The Long Ball: Upgrading Rails from 1.2 -> 4.0

The Long Ball: Upgrading Rails from 1.2 -> 4.0

RailsConf 2013 - Explore tips to upgrade from each major version to the other, and how to efficiently tackle a 1.2 -> 4.0 upgrade through two different case studies.
The velocity of change for Rails versions has a side effect -- businesses hesitate to update to the latest version until their productivity drops and they're forced to update. What happens then? Let's explore a case study of a Rails app that followed this pattern.

3b5cb0411cbd1012acab1b60f7ce3606?s=128

Jesse Wolgamott

May 02, 2013
Tweet

Transcript

  1. The Long Ball: Upgrading Rails From 1.2 → 4.0 Jesse

    Wolgamott | @jwo Thursday, May 2, 13
  2. Most Rails apps don't live as long as your entire

    career Thursday, May 2, 13
  3. but... what if they do? Thursday, May 2, 13

  4. Rails is not Wordpress and you cannot press "Upgrade". Thursday,

    May 2, 13
  5. In Rails, the code is changing constantly. Thursday, May 2,

    13
  6. Thursday, May 2, 13

  7. And this is a good thing Thursday, May 2, 13

  8. •Features •Security Updates •End of Life Thursday, May 2, 13

  9. there are many Rails 2.3 applications out there right now,

    chugging away and providing business value. Thursday, May 2, 13
  10. What should we do with them? Thursday, May 2, 13

  11. Life in a 1.x App Thursday, May 2, 13

  12. page.replace_html('tasks-completed', Task.completed_count) page.visual_effect(:highlight, 'task-item-' + @task.id.to_s, :duration => 1.0) http://viget.com/extend/getting-started-with-rjs-in-rails

    Thursday, May 2, 13
  13. <%= link_to_remote 'Mark as Complete', :update =>, 'task-status-' + @task.id.to_s,

    :url => {:controller => 'task', :action => 'mark_complete', :id => @task } %> http://viget.com/extend/getting-started-with-rjs-in-rails Thursday, May 2, 13
  14. svn import . svn://localhost/blab -m "initial import" -- username rbates

    cd ../ svn co svn://localhost/blab/trunk blab cd blab cp config/database_example.yml config/database.yml svn propset svn:ignore database.yml config/ svn propset svn:ignore "*" log/ svn propset svn:ignore "*" tmp/ http://railscasts.com/episodes/36-subversion-on-rails Thursday, May 2, 13
  15. Life in a 2.3 App Thursday, May 2, 13

  16. Rails::Initializer.run do |config| config.gem "haml" config.gem "chronic", :version => '0.2.3'

    config.gem "hpricot", :source => "http:// code.whytheluckystiff.net" config.gem "aws-s3", :lib => "aws/s3" end rake gems:install http://archives.ryandaigle.com/articles/2008/4/1/what-s- new-in-edge-rails-gem-dependencies Thursday, May 2, 13
  17. User.find(:all, :limit => 1) User.find(:all) User.find(:first) User.first(:conditions => {:name =>

    'lifo'}) User.all(:joins => :items) http://m.onkey.org/active-record-query-interface Thursday, May 2, 13
  18. How We Romanticize Rails 2.3 Thursday, May 2, 13

  19. Life in a 3.0 App Thursday, May 2, 13

  20. Article.where("published_at <= ?", Time.now).includes(:comments) scope :published, lambda { where(published: true)}

    Article.first http://railscasts.com/episodes/202-active-record-queries-in- rails-3 Thursday, May 2, 13
  21. class Person include ActiveModel::Validations attr_accessor :title validates :title, :presence =>

    true end Thursday, May 2, 13
  22. Railscasts::Application.routes.draw do root :to => "episodes#index" resources :spam_checks resources :spam_reports

    do member do post :confirm end end end http://railscasts.com/episodes/226-upgrading-to-rails-3- part-2 Thursday, May 2, 13
  23. Life in a 3.1 App Thursday, May 2, 13

  24. //= require jquery //= require jquery_ujs //= require_tree . http://guides.rubyonrails.org/asset_pipeline.html

    Thursday, May 2, 13
  25. /* *= require_self *= require_tree . */ http://guides.rubyonrails.org/asset_pipeline.html Thursday, May

    2, 13
  26. <script src="/assets/application-908e25f4bf6418 <link href="/assets/application-4dd5b109ee3439d http://guides.rubyonrails.org/asset_pipeline.html Thursday, May 2, 13

  27. Life in a 3.2 App Thursday, May 2, 13

  28. • .pluck(:id) • Better all around (faster) • mass_assignment (attr_accessible)

    Thursday, May 2, 13
  29. Quick look at 4.0 Thursday, May 2, 13

  30. • Wicked Awesome Postgres Features • Cooler Caching & strong_parameters

    • Turbolinks • Best Rails I’ve used Thursday, May 2, 13
  31. Upgrade by Rewrite Thursday, May 2, 13

  32. Upgrade by Refactor Thursday, May 2, 13

  33. The Decision to Rewrite is not a technical decision -

    it is a organizational decision Thursday, May 2, 13
  34. If you rewrite, you’ll likely fail Thursday, May 2, 13

  35. Fail to: Recreate every single feature Thursday, May 2, 13

  36. Fail to: Keep product momentum Thursday, May 2, 13

  37. Fail to: Show users you did anything worthwhile Thursday, May

    2, 13
  38. When should you rewrite? Thursday, May 2, 13

  39. php on Rails Thursday, May 2, 13

  40. Vendored Rails / Gems Thursday, May 2, 13

  41. Instead: Rewrite by Refactoring Tiny Wins Thursday, May 2, 13

  42. The main upgrade pains Thursday, May 2, 13

  43. Rails 2.3 Rails 3.0 Rails 3.1 Rails 4.0 Gems Router

    JavaScript Queries CSS JavaScript Forms Thursday, May 2, 13
  44. • Get to Rails 2.3 with bundler • Get to

    Rails 3.0 with Arel • Get to Rails 3.1 with Asset Pipeline • Get to Rails 4.0 with Gemfile updates Thursday, May 2, 13
  45. • Tip! use featured extracted gems during your 3.0 upgrade

    • prototype_rails • rails_autolink • deprecated_finders Thursday, May 2, 13
  46. Let's talk about Authentication Thursday, May 2, 13

  47. Thursday, May 2, 13

  48. Always be Upgrading Thursday, May 2, 13

  49. The Checklist Thursday, May 2, 13

  50. rails-upgrade- checklist.com Thursday, May 2, 13

  51. Thursday, May 2, 13

  52. Thursday, May 2, 13

  53. Thursday, May 2, 13

  54. @jwo Ruby o Rails rails-upgrade- checklist.com Thursday, May 2, 13