SlideShare a Scribd company logo
1 of 59
Download to read offline
Upgrading to
                          Rails 3
 OSCON 2010
Thursday, July 22, 2010
Michael Bleigh
                 @mbleigh

 OSCON 2010
Thursday, July 22, 2010
Thursday, July 22, 2010
Jeremy McAnally’s
                          Rails Upgrade Handbook
                             bit.ly/railsupgrade
 OSCON 2010
Thursday, July 22, 2010
Rails 3 is
                          Different
 OSCON 2010
Thursday, July 22, 2010
Rails 3 is a
                          Bi     ange
 OSCON 2010
Thursday, July 22, 2010
Why the hell
                    should I bother?

 OSCON 2010
Thursday, July 22, 2010
Modularity

 OSCON 2010
Thursday, July 22, 2010
Rails 2.3 Stack
                               ActiveRecord


                               ActiveSupport


                              ActiveResource


                                ActionPack


                                 Test::Unit




 OSCON 2010
Thursday, July 22, 2010
Rails 3 Ecosystem
                                          DataMapper
                           ActiveRecord                     MongoMapper

                                          ActiveSupport


                               ActiveResource            ActiveModel


                                           ActionPack

                              RSpec                             Bacon
                                            Test::Unit




 OSCON 2010
Thursday, July 22, 2010
Rails 2.3 Controller

                          ActionController::Base


                          ApplicationController


                             YourController




 OSCON 2010
Thursday, July 22, 2010
Rails 3 Controller
                              AbstractController::Base


                              ActionController::Metal


                               ActionController::Base


                               ApplicationController


                                  YourController



 OSCON 2010
Thursday, July 22, 2010
Less Monkeypatching



 OSCON 2010
Thursday, July 22, 2010
Security
   darwinbell via Flickr

 OSCON 2010
Thursday, July 22, 2010
small change,
                          big impact

 OSCON 2010
Thursday, July 22, 2010
HTML is escaped
                            by default.


 OSCON 2010
Thursday, July 22, 2010
<!-- Rails 2.3 -->
                  <div class='comment'>
                    <%= comment.body %>
                  </div>

                  <!-- Rails 3 -->
                  <div class="comment">
                    <%= comment.body.html_safe %>
                  </div>

                  <!-- Rails 3 (alternate) -->
                  <div class="comment">
                    <%=raw comment.body %>
                  </div>



Thursday, July 22, 2010
It’s a good   thing.TM




 OSCON 2010
Thursday, July 22, 2010
New Apis

 OSCON 2010
Thursday, July 22, 2010
e Router

 OSCON 2010
Thursday, July 22, 2010
Rack Everywhere!


 OSCON 2010
Thursday, July 22, 2010
Fancy New DSL


 OSCON 2010
Thursday, July 22, 2010
More Powerful

 OSCON 2010
Thursday, July 22, 2010
# Rails 2.3
                  map.connect '/help', :controller => 'pages',
                                       :action => 'help'

                  # Rails 3
                  match '/help', :to => 'pages#help'

                  # Rails 2.3
                  map.resources :users do |users|
                    users.resources :comments
                  end

                  # Rails 3
                  resources :users do
                    resources :comments
                  end




Thursday, July 22, 2010
# Rails 2.3
                  with_options :path_prefix => 'admin',
                               :name_prefix => 'admin' do |admin|
                    admin.resources :users
                    admin.resources :posts
                  end

                  # Rails 3
                  namespace :admin
                    resources :users
                    resources :posts
                  end




Thursday, July 22, 2010
# Rails 3

                  constraints(:subdomain => 'api') do
                    resources :statuses
                    resources :friends
                  end

                  match '/hello', :to => lambda{ |env|
                    [200, {'Content-Type' => 'text/plain'}, 'Hello
                  World']
                  }

                  match '/other-site', :to => redirect('http://url.com')




Thursday, July 22, 2010
A ionMailer

 OSCON 2010
Thursday, July 22, 2010
It’s (mostly) just
                       a controller.

 OSCON 2010
Thursday, July 22, 2010
class Notifier < ActionMailer::Base
                    default :from => "mikel@example.org"

                    def welcome_email(user)
                      @name = user.name
                      attachments['terms.pdf'] = File.read(
                        Rails.root.join('docs/terms.pdf')
                      )
                      mail(:to => user.email, :subject => "G’day Mate!")
                    end
                  end




Thursday, July 22, 2010
class UsersController < ApplicationController
                    respond_to :html
                    def create
                      @user = User.new(params[:user])

                      Notifier.welcome_email(@user).deliver if @user.save
                      respond_with @user
                    end
                  end




Thursday, July 22, 2010
Bundler

 OSCON 2010
Thursday, July 22, 2010
Caution: Entering
                   Controversy

 OSCON 2010
Thursday, July 22, 2010
# Rails 2.3

                  # environment.rb
                  config.gem 'acts-as-taggable-on'
                  config.gem 'ruby-openid', :lib => false

                  # test.rb
                  config.gem 'rspec'
                  config.gem 'cucumber'



                  # Rails 3

                  # Gemfile
                  gem 'acts-as-taggable-on'
                  gem 'ruby-openid', :require => false

                  group :test do
                    gem 'rspec'
                    gem 'cucumber'
                  end




Thursday, July 22, 2010
Dependency
                           Resolver

 OSCON 2010
Thursday, July 22, 2010
A iveRelation

 OSCON 2010
Thursday, July 22, 2010
Like named scopes,
                     only more so.


 OSCON 2010
Thursday, July 22, 2010
# Rails 2.3

                  Book.all(
                    :conditions => {:author => "Chuck Palahniuk"},
                    :order => "published_at DESC",
                    :limit => 10
                  )

                  # Rails 3

                  Book.where(:author => "Chuck Palahniuk")
                      .order("published_at DESC").limit(10)




Thursday, July 22, 2010
Inherently
                          Chainable

Thursday, July 22, 2010
# Rails 3

                  def index
                    @books = Book.where(:author => params[:author])
                  if params[:author]
                    @books = @books.order(:title) if params[:sort] ==
                  'title'
                    respond_with @books
                  end




Thursday, July 22, 2010
# Rails 2.3

                  class Book
                    named_scope :written_by {|a| {:conditions => {:author => a}}}
                    named_scope :after {|d| {:conditions => ["published_on > ?", d]}}
                  # Rails 3

                  class Book
                    class << self
                      def written_by(name)
                        where(:author => name)
                      end

                      def after(date)
                        where(["published_on > ?", date])
                      end
                    end
                  end




Thursday, July 22, 2010
Be er H ks

 OSCON 2010
Thursday, July 22, 2010
Generators

 OSCON 2010
Thursday, July 22, 2010
config.generators do   |g|
                    g.orm                :mongomapper
                    g.test_framework     :rspec
                    g.integration_tool   :rspec
                  end

                  rails g model my_model




Thursday, July 22, 2010
Engines

 OSCON 2010
Thursday, July 22, 2010
#lib/your_plugin/engine.rb
                  require "your_plugin"
                  require "rails"

                  module YourPlugin
                    class Engine < Rails::Engine
                      engine_name :your_plugin
                    end
                  end



Thursday, July 22, 2010
Lots more...
                     railsdispatch.com
                 edgeguides.rubyonrails.org



 OSCON 2010
Thursday, July 22, 2010
But we’re already
                     on Rails 2.3!

 OSCON 2010
Thursday, July 22, 2010
How do we cope?


 OSCON 2010
Thursday, July 22, 2010
Ignore it all
                           and cheat.
                          github.com/rails/
                           rails_upgrade

 OSCON 2010
Thursday, July 22, 2010
Finds Key
                           Blockers:
                          Routes, Bundler,
                           application.rb

 OSCON 2010
Thursday, July 22, 2010
3 Step Process

 OSCON 2010
Thursday, July 22, 2010
Analyze Your App
                 rake rails:upgrade:check




 OSCON 2010
Thursday, July 22, 2010
Backup 2.3 Files
                 rake rails:upgrade:backup




 OSCON 2010
Thursday, July 22, 2010
Run Upgrades
                  rake rails:upgrade:routes
                  rake rails:upgrade:gems
                  rake rails:upgrade:configuration




 OSCON 2010
Thursday, July 22, 2010
Takeaways

 OSCON 2010
Thursday, July 22, 2010
Tests help.
                    Unfortunately, they
                       may not run.


Thursday, July 22, 2010
Don’t be afraid to
                            re-generate.


Thursday, July 22, 2010
Just take it one
                          problem at a time.


Thursday, July 22, 2010
estions?
                          @mbleigh   @intridea
                 github.com/mbleigh/upgrade-to-rails3


 OSCON 2010
Thursday, July 22, 2010

More Related Content

Similar to Upgrading to Rails 3

Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices ThoughtWorks
 
Torquebox - O melhor dos dois mundos
Torquebox - O melhor dos dois mundosTorquebox - O melhor dos dois mundos
Torquebox - O melhor dos dois mundosBruno Oliveira
 
Frozen Rails Slides
Frozen Rails SlidesFrozen Rails Slides
Frozen Rails Slidescarllerche
 
Intro To MongoDB
Intro To MongoDBIntro To MongoDB
Intro To MongoDBAlex Sharp
 
Jquery Introduction
Jquery IntroductionJquery Introduction
Jquery Introductioncabbiepete
 
Mongodb on Ruby And Rails (froscon 2010)
Mongodb on Ruby And Rails (froscon 2010)Mongodb on Ruby And Rails (froscon 2010)
Mongodb on Ruby And Rails (froscon 2010)jan_mindmatters
 
RailsAdmin - the right way of doing data administration with Rails 3
RailsAdmin - the right way of doing data administration with Rails 3RailsAdmin - the right way of doing data administration with Rails 3
RailsAdmin - the right way of doing data administration with Rails 3Bogdan Gaza
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Bastian Hofmann
 
Akka scalaliftoff london_2010
Akka scalaliftoff london_2010Akka scalaliftoff london_2010
Akka scalaliftoff london_2010Skills Matter
 
Chef in the cloud [dbccg]
Chef in the cloud [dbccg]Chef in the cloud [dbccg]
Chef in the cloud [dbccg]jtimberman
 
HTML 5: The Future of the Web
HTML 5: The Future of the WebHTML 5: The Future of the Web
HTML 5: The Future of the WebTim Wright
 
The 3.5s Dash for Attention and Other Stuff We Found in RUM
The 3.5s Dash for Attention and Other Stuff We Found in RUMThe 3.5s Dash for Attention and Other Stuff We Found in RUM
The 3.5s Dash for Attention and Other Stuff We Found in RUMBuddy Brewer
 
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPIPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPGuilherme Blanco
 
how to rate a Rails application
how to rate a Rails applicationhow to rate a Rails application
how to rate a Rails applicationehuard
 
Scaling webappswithrabbitmq
Scaling webappswithrabbitmqScaling webappswithrabbitmq
Scaling webappswithrabbitmqAlvaro Videla
 
The Tech Side of Project Argo
The Tech Side of Project ArgoThe Tech Side of Project Argo
The Tech Side of Project ArgoWesley Lindamood
 
Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Matt Aimonetti
 

Similar to Upgrading to Rails 3 (20)

Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices
 
Torquebox - O melhor dos dois mundos
Torquebox - O melhor dos dois mundosTorquebox - O melhor dos dois mundos
Torquebox - O melhor dos dois mundos
 
Frozen Rails Slides
Frozen Rails SlidesFrozen Rails Slides
Frozen Rails Slides
 
Is these a bug
Is these a bugIs these a bug
Is these a bug
 
Intro To MongoDB
Intro To MongoDBIntro To MongoDB
Intro To MongoDB
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
Jquery Introduction
Jquery IntroductionJquery Introduction
Jquery Introduction
 
Mongodb on Ruby And Rails (froscon 2010)
Mongodb on Ruby And Rails (froscon 2010)Mongodb on Ruby And Rails (froscon 2010)
Mongodb on Ruby And Rails (froscon 2010)
 
RailsAdmin - the right way of doing data administration with Rails 3
RailsAdmin - the right way of doing data administration with Rails 3RailsAdmin - the right way of doing data administration with Rails 3
RailsAdmin - the right way of doing data administration with Rails 3
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
 
Akka scalaliftoff london_2010
Akka scalaliftoff london_2010Akka scalaliftoff london_2010
Akka scalaliftoff london_2010
 
Chef in the cloud [dbccg]
Chef in the cloud [dbccg]Chef in the cloud [dbccg]
Chef in the cloud [dbccg]
 
HTML 5: The Future of the Web
HTML 5: The Future of the WebHTML 5: The Future of the Web
HTML 5: The Future of the Web
 
The 3.5s Dash for Attention and Other Stuff We Found in RUM
The 3.5s Dash for Attention and Other Stuff We Found in RUMThe 3.5s Dash for Attention and Other Stuff We Found in RUM
The 3.5s Dash for Attention and Other Stuff We Found in RUM
 
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPIPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
 
how to rate a Rails application
how to rate a Rails applicationhow to rate a Rails application
how to rate a Rails application
 
Scaling webappswithrabbitmq
Scaling webappswithrabbitmqScaling webappswithrabbitmq
Scaling webappswithrabbitmq
 
The Tech Side of Project Argo
The Tech Side of Project ArgoThe Tech Side of Project Argo
The Tech Side of Project Argo
 
Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010
 

More from Michael Bleigh

OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)Michael Bleigh
 
OmniAuth: From the Ground Up
OmniAuth: From the Ground UpOmniAuth: From the Ground Up
OmniAuth: From the Ground UpMichael Bleigh
 
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)Michael Bleigh
 
Deciphering the Interoperable Web
Deciphering the Interoperable WebDeciphering the Interoperable Web
Deciphering the Interoperable WebMichael Bleigh
 
The Present Future of OAuth
The Present Future of OAuthThe Present Future of OAuth
The Present Future of OAuthMichael Bleigh
 
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)Michael Bleigh
 
Hacking the Mid-End (Great Lakes Ruby Bash Edition)
Hacking the Mid-End (Great Lakes Ruby Bash Edition)Hacking the Mid-End (Great Lakes Ruby Bash Edition)
Hacking the Mid-End (Great Lakes Ruby Bash Edition)Michael Bleigh
 

More from Michael Bleigh (9)

OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)
 
OmniAuth: From the Ground Up
OmniAuth: From the Ground UpOmniAuth: From the Ground Up
OmniAuth: From the Ground Up
 
The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)The Grapes of Rapid (RubyConf 2010)
The Grapes of Rapid (RubyConf 2010)
 
Deciphering the Interoperable Web
Deciphering the Interoperable WebDeciphering the Interoperable Web
Deciphering the Interoperable Web
 
The Present Future of OAuth
The Present Future of OAuthThe Present Future of OAuth
The Present Future of OAuth
 
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)
 
Persistence Smoothie
Persistence SmoothiePersistence Smoothie
Persistence Smoothie
 
Twitter on Rails
Twitter on RailsTwitter on Rails
Twitter on Rails
 
Hacking the Mid-End (Great Lakes Ruby Bash Edition)
Hacking the Mid-End (Great Lakes Ruby Bash Edition)Hacking the Mid-End (Great Lakes Ruby Bash Edition)
Hacking the Mid-End (Great Lakes Ruby Bash Edition)
 

Recently uploaded

Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Upgrading to Rails 3

  • 1. Upgrading to Rails 3 OSCON 2010 Thursday, July 22, 2010
  • 2. Michael Bleigh @mbleigh OSCON 2010 Thursday, July 22, 2010
  • 4. Jeremy McAnally’s Rails Upgrade Handbook bit.ly/railsupgrade OSCON 2010 Thursday, July 22, 2010
  • 5. Rails 3 is Different OSCON 2010 Thursday, July 22, 2010
  • 6. Rails 3 is a Bi ange OSCON 2010 Thursday, July 22, 2010
  • 7. Why the hell should I bother? OSCON 2010 Thursday, July 22, 2010
  • 9. Rails 2.3 Stack ActiveRecord ActiveSupport ActiveResource ActionPack Test::Unit OSCON 2010 Thursday, July 22, 2010
  • 10. Rails 3 Ecosystem DataMapper ActiveRecord MongoMapper ActiveSupport ActiveResource ActiveModel ActionPack RSpec Bacon Test::Unit OSCON 2010 Thursday, July 22, 2010
  • 11. Rails 2.3 Controller ActionController::Base ApplicationController YourController OSCON 2010 Thursday, July 22, 2010
  • 12. Rails 3 Controller AbstractController::Base ActionController::Metal ActionController::Base ApplicationController YourController OSCON 2010 Thursday, July 22, 2010
  • 13. Less Monkeypatching OSCON 2010 Thursday, July 22, 2010
  • 14. Security darwinbell via Flickr OSCON 2010 Thursday, July 22, 2010
  • 15. small change, big impact OSCON 2010 Thursday, July 22, 2010
  • 16. HTML is escaped by default. OSCON 2010 Thursday, July 22, 2010
  • 17. <!-- Rails 2.3 --> <div class='comment'> <%= comment.body %> </div> <!-- Rails 3 --> <div class="comment"> <%= comment.body.html_safe %> </div> <!-- Rails 3 (alternate) --> <div class="comment"> <%=raw comment.body %> </div> Thursday, July 22, 2010
  • 18. It’s a good thing.TM OSCON 2010 Thursday, July 22, 2010
  • 19. New Apis OSCON 2010 Thursday, July 22, 2010
  • 20. e Router OSCON 2010 Thursday, July 22, 2010
  • 21. Rack Everywhere! OSCON 2010 Thursday, July 22, 2010
  • 22. Fancy New DSL OSCON 2010 Thursday, July 22, 2010
  • 23. More Powerful OSCON 2010 Thursday, July 22, 2010
  • 24. # Rails 2.3 map.connect '/help', :controller => 'pages', :action => 'help' # Rails 3 match '/help', :to => 'pages#help' # Rails 2.3 map.resources :users do |users| users.resources :comments end # Rails 3 resources :users do resources :comments end Thursday, July 22, 2010
  • 25. # Rails 2.3 with_options :path_prefix => 'admin', :name_prefix => 'admin' do |admin| admin.resources :users admin.resources :posts end # Rails 3 namespace :admin resources :users resources :posts end Thursday, July 22, 2010
  • 26. # Rails 3 constraints(:subdomain => 'api') do resources :statuses resources :friends end match '/hello', :to => lambda{ |env| [200, {'Content-Type' => 'text/plain'}, 'Hello World'] } match '/other-site', :to => redirect('http://url.com') Thursday, July 22, 2010
  • 27. A ionMailer OSCON 2010 Thursday, July 22, 2010
  • 28. It’s (mostly) just a controller. OSCON 2010 Thursday, July 22, 2010
  • 29. class Notifier < ActionMailer::Base default :from => "mikel@example.org" def welcome_email(user) @name = user.name attachments['terms.pdf'] = File.read( Rails.root.join('docs/terms.pdf') ) mail(:to => user.email, :subject => "G’day Mate!") end end Thursday, July 22, 2010
  • 30. class UsersController < ApplicationController respond_to :html def create @user = User.new(params[:user]) Notifier.welcome_email(@user).deliver if @user.save respond_with @user end end Thursday, July 22, 2010
  • 32. Caution: Entering Controversy OSCON 2010 Thursday, July 22, 2010
  • 33. # Rails 2.3 # environment.rb config.gem 'acts-as-taggable-on' config.gem 'ruby-openid', :lib => false # test.rb config.gem 'rspec' config.gem 'cucumber' # Rails 3 # Gemfile gem 'acts-as-taggable-on' gem 'ruby-openid', :require => false group :test do gem 'rspec' gem 'cucumber' end Thursday, July 22, 2010
  • 34. Dependency Resolver OSCON 2010 Thursday, July 22, 2010
  • 35. A iveRelation OSCON 2010 Thursday, July 22, 2010
  • 36. Like named scopes, only more so. OSCON 2010 Thursday, July 22, 2010
  • 37. # Rails 2.3 Book.all( :conditions => {:author => "Chuck Palahniuk"}, :order => "published_at DESC", :limit => 10 ) # Rails 3 Book.where(:author => "Chuck Palahniuk") .order("published_at DESC").limit(10) Thursday, July 22, 2010
  • 38. Inherently Chainable Thursday, July 22, 2010
  • 39. # Rails 3 def index @books = Book.where(:author => params[:author]) if params[:author] @books = @books.order(:title) if params[:sort] == 'title' respond_with @books end Thursday, July 22, 2010
  • 40. # Rails 2.3 class Book named_scope :written_by {|a| {:conditions => {:author => a}}} named_scope :after {|d| {:conditions => ["published_on > ?", d]}} # Rails 3 class Book class << self def written_by(name) where(:author => name) end def after(date) where(["published_on > ?", date]) end end end Thursday, July 22, 2010
  • 41. Be er H ks OSCON 2010 Thursday, July 22, 2010
  • 43. config.generators do |g| g.orm :mongomapper g.test_framework :rspec g.integration_tool :rspec end rails g model my_model Thursday, July 22, 2010
  • 45. #lib/your_plugin/engine.rb require "your_plugin" require "rails" module YourPlugin class Engine < Rails::Engine engine_name :your_plugin end end Thursday, July 22, 2010
  • 46. Lots more... railsdispatch.com edgeguides.rubyonrails.org OSCON 2010 Thursday, July 22, 2010
  • 47. But we’re already on Rails 2.3! OSCON 2010 Thursday, July 22, 2010
  • 48. How do we cope? OSCON 2010 Thursday, July 22, 2010
  • 49. Ignore it all and cheat. github.com/rails/ rails_upgrade OSCON 2010 Thursday, July 22, 2010
  • 50. Finds Key Blockers: Routes, Bundler, application.rb OSCON 2010 Thursday, July 22, 2010
  • 51. 3 Step Process OSCON 2010 Thursday, July 22, 2010
  • 52. Analyze Your App rake rails:upgrade:check OSCON 2010 Thursday, July 22, 2010
  • 53. Backup 2.3 Files rake rails:upgrade:backup OSCON 2010 Thursday, July 22, 2010
  • 54. Run Upgrades rake rails:upgrade:routes rake rails:upgrade:gems rake rails:upgrade:configuration OSCON 2010 Thursday, July 22, 2010
  • 56. Tests help. Unfortunately, they may not run. Thursday, July 22, 2010
  • 57. Don’t be afraid to re-generate. Thursday, July 22, 2010
  • 58. Just take it one problem at a time. Thursday, July 22, 2010
  • 59. estions? @mbleigh @intridea github.com/mbleigh/upgrade-to-rails3 OSCON 2010 Thursday, July 22, 2010