SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
ONE DOES NOT SIMPLY
UPGRADE TO RAILS 3
Adventures in Upgrading
From Rails 2 to 3
Chris McCann
@testflyjets
github.com/testflyjets
The Task
Upgrade a Rails 2.3.5 app to Rails 3.1
Ultimately upgrade to Rails 4
Why?
Benefits to Upgrading
Security patches
Ruby 2.0
New gems and capabilities, Bundler
Asset pipeline + Sass
Framework improvements, speed
Improve test coverage (spoiler: easy!)
The App
First app I ever built
Started in 2007
Rails 1.2 initially
Upgraded to 2.3.5
2nd Edition
The App
!
Monkey-patched gems
(mysql, geokit, DJ)
Lots of plugins
Prototype helpers...lots
The App
CSS mess
Homebrewed
authentication
The App
163 models
167 controllers
> 1,000 view templates
12,500 users
Over $500,000 in non-
profit transactions
Testing to the rescue!
Not so much
Resources for Upgrading
Episodes 225, 226, 227
My Hybrid Approach*
Create a new Rails 3 app
Install Rails 3 versions of gems, replace plugins
Get the framework running with config from old app
The first goal is to get to:
* Thanks to Rob Kaufman @ Notch8
$ rails console !
$ irb(main):001:0>
MySQL
Originally MySQL 5.1 + mysql gem + monkey patch
Not compatible with Rails 3 >> MySQL 5.5 + mysql2
Broke original app on dev machine because it can’t use
MySQL 5.5 (bad handshake, disconnect errors)
Solution: live with it (have 2nd dev machine)
Plugin > gem conversion
Generally not too terrible
Most plugins available as Rails 3 gems
Can still use vendor/plugins if necessary
Spoiler alert: you won’t find all the problems initially
Framework configuration
Custom configuration code moved from
environment.rb to application.rb
Initializers used extensively in Rails 3
autoload paths (like /lib) need to be specified
parameter filtering (passwords, credit card numbers)
now in application.rb not in controllers
Solution: just gut it out until things work
UDT: Upgrade Driven Testing
Tests as sanity checks
Try to rapidly touch every model to trigger failures
Tools of choice: rspec, factory_girl, spork, faker
Script to generate specs and factories for all models:
rails generate rspec:model #{model_file} -s
“Canary in a coal mine” tests
I didn’t find a quick way to check my models
Specs you don’t write are all “pending”
Hidden land mine: attr_accessible
Model changes everywhere
named_scope became scope plus syntax changes
(deprecation)
validates_* to validates (*attributes)!
Had to update for rspec matchers to work
ActiveModel find syntax changes (deprecation)
ActionMailer failer
ActionMailer methods
Mailer methods changed:
create_* and deliver_* are gone
email = Mailer.confirm(user)
email.deliver!
@body[“instance_var”] to @instance_var
ActionMailer views
Mailer views renamed:
*.text.html.erb to *.html.erb
*.plain.text.erb to *.text.erb!
*.rhtml is completely deprecated, will fail
Solution: easy to test them, trigger failures, fix ‘em
Gotcha: links in your emails? How’s your routes.rb?
Routing changes
Joys of RESTful routing
Original app had mix of RESTful and controller/action
Bad, bad, bad: Catch-all route
map.connect ‘:controller/:action/:id.:format’
Routing syntax tedium
	
  	
  	
  	
  	
  
flight.resource	
  :roster_import,	
  :controller	
  =>	
  :import,	
  	
  
	
  	
  	
  	
  	
  	
  :only	
  =>	
  [:new,	
  :create],	
  
	
  	
  	
  	
  	
  	
  :member	
  =>	
  {	
  :import_csv	
  	
  =>	
  :get,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :import_setup	
  =>	
  :get,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  :match_imports	
  =>	
  :get	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  
!
	
  	
  	
  	
  resource	
  :roster_import,	
  controller:	
  'import',	
  	
  
only:	
  [:new,	
  :create]	
  do	
  
	
  	
  	
  	
  	
  	
  member	
  do	
  
	
  	
  	
  	
  	
  	
  	
  	
  get	
  'import_csv'	
  
	
  	
  	
  	
  	
  	
  	
  	
  get	
  'import_setup'	
  
	
  	
  	
  	
  	
  	
  	
  	
  get	
  'match_imports'	
  
	
  	
  	
  	
  	
  	
  end	
  
	
  	
  	
  	
  end	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  
Controller Testing
Hoped for a straightforward way to sanity check
request specs vs controller specs?
rspec let() vs @var : association issues
Bottom line: steep learning curve but necessary
Asset Pipeline
Asset Pipeline partially implemented already
Managed to double-include some files
Watch out for relative paths between JS and CSS
Overall: not terrible, probably easier without “poor
man’s pipeline”
View booby traps
Views can be a pain to test
Over 1,000 view templates in the app
ERB changes to look for:
<% form_for ...%> to <%= form_for ...%>!
Using raw to escape HTML built in strings (helpers)
No more Prototype helpers
Prototype helpers removed
remote_form_for!
form_remote_tag!
link_to_remote!
remote_function!
Ajax form/links now done with remote: true
Prototype callbacks
link_to_remote(dues.email_link, !
:url => send_notices_flight_dues_path(@flight, dues),!
:before => "Element.show('spinner')",!
:complete => "Element.hide('spinner')",!
:method! => :post,!
:confirm => confirm) !
!
!
link_to(dues.email_link, !
send_notices_flight_dues_path(@flight, dues),!
remote: true, !
method: :post, !
confirm: confirm) !
Use jQuery for callbacks
application.js!
!
$("*[data-spinner]")!
.on("ajax:before", function(){ !
$($(this).data('spinner')).show(); !
})!
.on("ajax:complete", function(xhr, status){ !
$($(this).data('spinner')).hide(); !
})!
Geocoding and GMap
Used geokit, monkey-patched for exception handling
during auto-geocoding
Google killed GMaps v2 last fall
New geokit-rails for Rails 3: used v2, no “distance” field
Solution: replace geokit-rails with geocoder
tl;dr
Upgrading between major versions is hard
Not having tests makes it MUCH harder
Incremental upgrade is way easier
For a large project, it simply takes time and effort
Retrofit tests as you go -- you’ll need them someday
ONE DOES NOT SIMPLY
UPGRADE TO RAILS 3
Adventures in Upgrading
From Rails 2 to 3
Chris McCann
@testflyjets
github.com/testflyjets

Contenu connexe

Tendances

RBC Mod 1: Making a New Rails App
RBC Mod 1: Making a New Rails AppRBC Mod 1: Making a New Rails App
RBC Mod 1: Making a New Rails Appameedahc
 
Exposing Salesforce REST Services Using Swagger
Exposing Salesforce REST Services Using SwaggerExposing Salesforce REST Services Using Swagger
Exposing Salesforce REST Services Using SwaggerSalesforce Developers
 
Building an API using Grape
Building an API using GrapeBuilding an API using Grape
Building an API using Grapevisnu priya
 
React Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + AuthenticationReact Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + AuthenticationKobkrit Viriyayudhakorn
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$Joe Ferguson
 
Frail & Cast Iron tools - a Postman Case Study
Frail & Cast Iron tools - a Postman Case StudyFrail & Cast Iron tools - a Postman Case Study
Frail & Cast Iron tools - a Postman Case StudyPostman
 
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Lorvent56
 
Connecting Connect with Spring Boot
Connecting Connect with Spring BootConnecting Connect with Spring Boot
Connecting Connect with Spring BootVincent Kok
 
All Aboard for Laravel 5.1
All Aboard for Laravel 5.1All Aboard for Laravel 5.1
All Aboard for Laravel 5.1Jason McCreary
 
Laravel 5 New Features
Laravel 5 New FeaturesLaravel 5 New Features
Laravel 5 New FeaturesJoe Ferguson
 
Using JHipster 4 for generating Angular/Spring Boot apps
Using JHipster 4 for generating Angular/Spring Boot appsUsing JHipster 4 for generating Angular/Spring Boot apps
Using JHipster 4 for generating Angular/Spring Boot appsYakov Fain
 
Building Ambitious Web Apps with Ember
Building Ambitious Web Apps with EmberBuilding Ambitious Web Apps with Ember
Building Ambitious Web Apps with Embergbabiars
 
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017VMware Tanzu
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsYakov Fain
 

Tendances (20)

RBC Mod 1: Making a New Rails App
RBC Mod 1: Making a New Rails AppRBC Mod 1: Making a New Rails App
RBC Mod 1: Making a New Rails App
 
Exposing Salesforce REST Services Using Swagger
Exposing Salesforce REST Services Using SwaggerExposing Salesforce REST Services Using Swagger
Exposing Salesforce REST Services Using Swagger
 
Workshop Laravel 5.2
Workshop Laravel 5.2Workshop Laravel 5.2
Workshop Laravel 5.2
 
Rails introduction
Rails introductionRails introduction
Rails introduction
 
Building an API using Grape
Building an API using GrapeBuilding an API using Grape
Building an API using Grape
 
Spring boot
Spring bootSpring boot
Spring boot
 
React Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + AuthenticationReact Native Firebase Realtime Database + Authentication
React Native Firebase Realtime Database + Authentication
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
Frail & Cast Iron tools - a Postman Case Study
Frail & Cast Iron tools - a Postman Case StudyFrail & Cast Iron tools - a Postman Case Study
Frail & Cast Iron tools - a Postman Case Study
 
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
 
Connecting Connect with Spring Boot
Connecting Connect with Spring BootConnecting Connect with Spring Boot
Connecting Connect with Spring Boot
 
All Aboard for Laravel 5.1
All Aboard for Laravel 5.1All Aboard for Laravel 5.1
All Aboard for Laravel 5.1
 
Laravel 5 New Features
Laravel 5 New FeaturesLaravel 5 New Features
Laravel 5 New Features
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Using JHipster 4 for generating Angular/Spring Boot apps
Using JHipster 4 for generating Angular/Spring Boot appsUsing JHipster 4 for generating Angular/Spring Boot apps
Using JHipster 4 for generating Angular/Spring Boot apps
 
Building Ambitious Web Apps with Ember
Building Ambitious Web Apps with EmberBuilding Ambitious Web Apps with Ember
Building Ambitious Web Apps with Ember
 
Chef conf-2014
Chef conf-2014Chef conf-2014
Chef conf-2014
 
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
Stéphane Nicoll and Madhura Bhave at SpringOne Platform 2017
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
 

Similaire à One does not simply "Upgrade to Rails 3"

Using Rails to Create an Enterprise App: A Real-Life Case Study
Using Rails to Create an Enterprise App: A Real-Life Case StudyUsing Rails to Create an Enterprise App: A Real-Life Case Study
Using Rails to Create an Enterprise App: A Real-Life Case StudyDavid Keener
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2Rory Gianni
 
Migration from Rails2 to Rails3
Migration from Rails2 to Rails3Migration from Rails2 to Rails3
Migration from Rails2 to Rails3Umair Amjad
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataStacy London
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataColdFusionConference
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with RailsAll Things Open
 
The road to Ember.js 2.0
The road to Ember.js 2.0The road to Ember.js 2.0
The road to Ember.js 2.0Codemotion
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsMike Subelsky
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsAlessandro DS
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?Srijan Technologies
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorialsunniboy
 
Ember presentation
Ember presentationEmber presentation
Ember presentationDaniel N
 
Server and client rendering of single page apps
Server and client rendering of single page appsServer and client rendering of single page apps
Server and client rendering of single page appsThomas Heymann
 

Similaire à One does not simply "Upgrade to Rails 3" (20)

Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Using Rails to Create an Enterprise App: A Real-Life Case Study
Using Rails to Create an Enterprise App: A Real-Life Case StudyUsing Rails to Create an Enterprise App: A Real-Life Case Study
Using Rails to Create an Enterprise App: A Real-Life Case Study
 
Speedy TDD with Rails
Speedy TDD with RailsSpeedy TDD with Rails
Speedy TDD with Rails
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2
 
Migration from Rails2 to Rails3
Migration from Rails2 to Rails3Migration from Rails2 to Rails3
Migration from Rails2 to Rails3
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with Rails
 
The road to Ember.js 2.0
The road to Ember.js 2.0The road to Ember.js 2.0
The road to Ember.js 2.0
 
Full slidescr16
Full slidescr16Full slidescr16
Full slidescr16
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
 
Workshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte IWorkshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte I
 
TorqueBox
TorqueBoxTorqueBox
TorqueBox
 
Ember presentation
Ember presentationEmber presentation
Ember presentation
 
Server and client rendering of single page apps
Server and client rendering of single page appsServer and client rendering of single page apps
Server and client rendering of single page apps
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Dernier (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

One does not simply "Upgrade to Rails 3"

  • 1. ONE DOES NOT SIMPLY UPGRADE TO RAILS 3
  • 2. Adventures in Upgrading From Rails 2 to 3 Chris McCann @testflyjets github.com/testflyjets
  • 3. The Task Upgrade a Rails 2.3.5 app to Rails 3.1 Ultimately upgrade to Rails 4
  • 5. Benefits to Upgrading Security patches Ruby 2.0 New gems and capabilities, Bundler Asset pipeline + Sass Framework improvements, speed Improve test coverage (spoiler: easy!)
  • 6. The App First app I ever built Started in 2007 Rails 1.2 initially Upgraded to 2.3.5 2nd Edition
  • 7. The App ! Monkey-patched gems (mysql, geokit, DJ) Lots of plugins Prototype helpers...lots
  • 9. The App 163 models 167 controllers > 1,000 view templates 12,500 users Over $500,000 in non- profit transactions
  • 10. Testing to the rescue!
  • 13. My Hybrid Approach* Create a new Rails 3 app Install Rails 3 versions of gems, replace plugins Get the framework running with config from old app The first goal is to get to: * Thanks to Rob Kaufman @ Notch8 $ rails console ! $ irb(main):001:0>
  • 14.
  • 15. MySQL Originally MySQL 5.1 + mysql gem + monkey patch Not compatible with Rails 3 >> MySQL 5.5 + mysql2 Broke original app on dev machine because it can’t use MySQL 5.5 (bad handshake, disconnect errors) Solution: live with it (have 2nd dev machine)
  • 16. Plugin > gem conversion Generally not too terrible Most plugins available as Rails 3 gems Can still use vendor/plugins if necessary Spoiler alert: you won’t find all the problems initially
  • 17. Framework configuration Custom configuration code moved from environment.rb to application.rb Initializers used extensively in Rails 3 autoload paths (like /lib) need to be specified parameter filtering (passwords, credit card numbers) now in application.rb not in controllers Solution: just gut it out until things work
  • 19. Tests as sanity checks Try to rapidly touch every model to trigger failures Tools of choice: rspec, factory_girl, spork, faker Script to generate specs and factories for all models: rails generate rspec:model #{model_file} -s
  • 20.
  • 21. “Canary in a coal mine” tests I didn’t find a quick way to check my models Specs you don’t write are all “pending” Hidden land mine: attr_accessible
  • 22. Model changes everywhere named_scope became scope plus syntax changes (deprecation) validates_* to validates (*attributes)! Had to update for rspec matchers to work ActiveModel find syntax changes (deprecation)
  • 24. ActionMailer methods Mailer methods changed: create_* and deliver_* are gone email = Mailer.confirm(user) email.deliver! @body[“instance_var”] to @instance_var
  • 25. ActionMailer views Mailer views renamed: *.text.html.erb to *.html.erb *.plain.text.erb to *.text.erb! *.rhtml is completely deprecated, will fail Solution: easy to test them, trigger failures, fix ‘em Gotcha: links in your emails? How’s your routes.rb?
  • 27. Joys of RESTful routing Original app had mix of RESTful and controller/action Bad, bad, bad: Catch-all route map.connect ‘:controller/:action/:id.:format’
  • 28. Routing syntax tedium           flight.resource  :roster_import,  :controller  =>  :import,                :only  =>  [:new,  :create],              :member  =>  {  :import_csv    =>  :get,                                        :import_setup  =>  :get,                                        :match_imports  =>  :get  }                                           !        resource  :roster_import,  controller:  'import',     only:  [:new,  :create]  do              member  do                  get  'import_csv'                  get  'import_setup'                  get  'match_imports'              end          end                                        
  • 29. Controller Testing Hoped for a straightforward way to sanity check request specs vs controller specs? rspec let() vs @var : association issues Bottom line: steep learning curve but necessary
  • 30. Asset Pipeline Asset Pipeline partially implemented already Managed to double-include some files Watch out for relative paths between JS and CSS Overall: not terrible, probably easier without “poor man’s pipeline”
  • 31. View booby traps Views can be a pain to test Over 1,000 view templates in the app ERB changes to look for: <% form_for ...%> to <%= form_for ...%>! Using raw to escape HTML built in strings (helpers)
  • 32. No more Prototype helpers
  • 34. Prototype callbacks link_to_remote(dues.email_link, ! :url => send_notices_flight_dues_path(@flight, dues),! :before => "Element.show('spinner')",! :complete => "Element.hide('spinner')",! :method! => :post,! :confirm => confirm) ! ! ! link_to(dues.email_link, ! send_notices_flight_dues_path(@flight, dues),! remote: true, ! method: :post, ! confirm: confirm) !
  • 35. Use jQuery for callbacks application.js! ! $("*[data-spinner]")! .on("ajax:before", function(){ ! $($(this).data('spinner')).show(); ! })! .on("ajax:complete", function(xhr, status){ ! $($(this).data('spinner')).hide(); ! })!
  • 36.
  • 37. Geocoding and GMap Used geokit, monkey-patched for exception handling during auto-geocoding Google killed GMaps v2 last fall New geokit-rails for Rails 3: used v2, no “distance” field Solution: replace geokit-rails with geocoder
  • 38. tl;dr Upgrading between major versions is hard Not having tests makes it MUCH harder Incremental upgrade is way easier For a large project, it simply takes time and effort Retrofit tests as you go -- you’ll need them someday
  • 39. ONE DOES NOT SIMPLY UPGRADE TO RAILS 3
  • 40. Adventures in Upgrading From Rails 2 to 3 Chris McCann @testflyjets github.com/testflyjets