SlideShare a Scribd company logo
1 of 91
Download to read offline
Rails 3 Through
                             Choices
                                  Nick Sieger
                           nsieger@engineyard.com



Sunday, March 21, 2010
Nick




Sunday, March 21, 2010
@


Sunday, March 21, 2010
EY Cloud




Sunday, March 21, 2010
EY Open Source

                           Rails      JRuby



                          Rubinius   Ruby 1.8.6



Sunday, March 21, 2010
Topic



Sunday, March 21, 2010
3


Sunday, March 21, 2010
Sunday, March 21, 2010
Confession



Sunday, March 21, 2010
I’m not a web
                           developer


Sunday, March 21, 2010
Sunday, March 21, 2010
HTML           JSON
                   JavaScript       SQL
               CSS                XML
                         Ruby
     HTTP                            DNS
                         TCP/IP            Nginx
               Apache         FCGI    Memcached
Sunday, March 21, 2010
HTML           JSON
          JavaScript       SQL
      CSS
     HTTP             DNS
                         Ruby
                         XML

           TCP/IP         Nginx
      Apache    FCGI Memcached
Sunday, March 21, 2010
=
Sunday, March 21, 2010
Ruby
                         in 2010




Sunday, March 21, 2010
Sunday, March 21, 2010
Sunday, March 21, 2010
Ruby VMs



Sunday, March 21, 2010
Ruby 1.8
                         almost seven years old!




Sunday, March 21, 2010
Ruby 1.9.2
                           August 2010




Sunday, March 21, 2010
JRuby 1.5
                           April 2010




Sunday, March 21, 2010
Rubinius 1.0
                             Q2 2010




Sunday, March 21, 2010
Ruby 2.0
                         Let the prognostication begin




Sunday, March 21, 2010
Sunday, March 21, 2010
Sunday, March 21, 2010
Sunday, March 21, 2010
Sunday, March 21, 2010
Sunday, March 21, 2010
i
Sunday, March 21, 2010
paralyzed by
                            choice


Sunday, March 21, 2010
Sunday, March 21, 2010
Sunday, March 21, 2010
Sunday, March 21, 2010
opinionated
                          software


Sunday, March 21, 2010
making
                         choices


Sunday, March 21, 2010
Sunday, March 21, 2010
6 years later...



Sunday, March 21, 2010
Sunday, March 21, 2010
Sunday, March 21, 2010
Sunday, March 21, 2010
Rails 3
                          highlights




Sunday, March 21, 2010
Rails command
$ rails newapp
      create
      create README
      create .gitignore
      create Rakefile
      create config.ru
      create Gemfile
      create app
      create app/controllers/application_controller.rb
      create app/helpers/application_helper.rb
      create app/models
      create app/views/layouts
      create config
      ...
Sunday, March 21, 2010
Options
$ rails -h
Usage:
  rails APP_PATH [options]

Options:
  ...
  -O, [--skip-activerecord]   # Skip ActiveRecord files
  -T, [--skip-testunit]       # Skip TestUnit files
  -J, [--skip-prototype]      # Skip Prototype files




Sunday, March 21, 2010
Script
                                  script/rails s
                                  script/rails g
           script/server          script/rails c
           script/generate
           script/console         rails server
                                  rails generate
                                  rails console




Sunday, March 21, 2010
Layout




Sunday, March 21, 2010
Classes
                  class MyController < ApplicationController
                  end



                  class MyModel < ActiveRecord::Base
                  end




Sunday, March 21, 2010
Unobtrusive
                          JavaScript


Sunday, March 21, 2010
JavaScript: R2
  link_to "Delete Image", @image,
    :confirm => "Are you sure?", :method => :delete


  <a href="/images/9" onclick="if (confirm('Are you
  sure?')) { var f = document.createElement('form');
  f.style.display = 'none'; this.parentNode.appendChild
  (f); f.method = 'POST'; f.action = this.href; var m =
  document.createElement('input'); m.setAttribute('type',
  'hidden'); m.setAttribute('name', '_method');
  m.setAttribute('value', 'delete'); f.appendChild
  (m);f.submit(); };return false;">Delete Image</a>

Sunday, March 21, 2010
JavaScript: R3
  link_to "Delete Image", @image,
    :confirm => "Are you sure?", :method => :delete




  <a href="/images/9" rel="nofollow" data-method="delete"
  data-confirm="Are you sure?">Delete Image</a>




Sunday, March 21, 2010
XSS Safety



Sunday, March 21, 2010
XSS Safety: R2

                           <%= h safe_value %>

                           <%= unsafe_value %>




Sunday, March 21, 2010
XSS Safety: R3

                           <%= safe_value %>

                           <%= raw unsafe_value %>




Sunday, March 21, 2010
Routing



Sunday, March 21, 2010
Routing: R2
              map.connect 'products/:id',
                :controller => 'catalog', :action => 'view'


              map.resources :products do |products|
                products.resources :comments
                products.resources :sales,
                  :collection => { :recent => :get }
              end



Sunday, March 21, 2010
Routing: R3
              match 'products/:id' => 'catalog#view'


              resources :products do
                resources :comments
                resources :sales do
                  get :recent, :on => :collection
                end
              end



Sunday, March 21, 2010
More

                    • Cleaner ActionMailer
                    • ActiveRecord lazy queries
                    • ...
Sunday, March 21, 2010
First Online
                             RailsConf
                         http://bit.ly/online-railsconf-slides




Sunday, March 21, 2010
APIs as Glue




Sunday, March 21, 2010
Railties




Sunday, March 21, 2010
The Extension API
                              for Rails


Sunday, March 21, 2010
Decoupling
                         http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/




Sunday, March 21, 2010
Decoupling
                         http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/




                                                    ActionView


                                  ActionController
                                                            ActiveRecord




Sunday, March 21, 2010
Decoupling
                         http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/




                     ActionController               ActionView             ActiveRecord




Sunday, March 21, 2010
Decoupling
                         http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/




                     ActionController               ActionView             ActiveRecord




Sunday, March 21, 2010
Decoupling
                           http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/



                         ActionDispatch



                   AbstractController




                     ActionController                 ActionView             ActiveRecord




Sunday, March 21, 2010
Decoupling
                           http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/



                         ActionDispatch


                                                         View
                   AbstractController                   Context




                     ActionController                 ActionView             ActiveRecord




Sunday, March 21, 2010
Decoupling
                           http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/



                         ActionDispatch


                                                         View
                                                                              ActiveModel
                   AbstractController                   Context




                     ActionController                 ActionView             ActiveRecord




Sunday, March 21, 2010
Encapsulate
                         what varies


Sunday, March 21, 2010
Railties:
                         Configuration
                         encapsulated


Sunday, March 21, 2010
Railtie Elements

         Initialization           Generators


             Rake Tasks         Logging Events


Sunday, March 21, 2010
Example

 require 'rails/railtie'

 class MemCacheClusterRailtie < Rails::Railtie
   initializer :setup_mem_cache_cluster do |app|
     app.config.cache_store = [
       :mem_cache_store, 'cache1:11211', 'cache2:11211']
   end
 end



Sunday, March 21, 2010
Rails’ Railties

        ActionController::       ActionDispatch::
              Railtie                 Railtie


              ActiveRecord::      ActionMailer::
                  Railtie             Railtie


Sunday, March 21, 2010
Rails::Railtie




                         Rails::Application



Sunday, March 21, 2010
Init: Rails 2
    def process
      Rails.configuration = configuration

        check_ruby_version
        install_gem_spec_stubs
        set_load_path
        add_gem_load_paths

        require_frameworks
        set_autoload_paths
        add_plugin_load_paths
        load_environment
        preload_frameworks

        initialize_encoding
        initialize_database

        initialize_cache
        initialize_framework_caches

        initialize_logger
        initialize_framework_logging

        initialize_dependency_mechanism
Sunday, March 21, 2010
load_application_initializers

        # the framework is now fully initialized


                             Init: Rails 2
        after_initialize

        # Setup database middleware after initializers have run
        initialize_database_middleware

        # Prepare dispatcher callbacks and run 'prepare' callbacks
        prepare_dispatcher

        # Routing must be initialized after plugins to allow the former to extend the routes
        initialize_routing

      # Observers are loaded after plugins in case Observers or observed models are modified by
    plugins.
      load_observers

        # Load view path cache
        load_view_paths

        # Load application classes
        load_application_classes

        # Disable dependency loading during request cycle
        disable_dependency_loading

      # Flag initialized
      Rails.initialized = true
    end

Sunday, March 21, 2010
Init: Rails 3

                         class Rails::Application
                           def initialize!
                             run_initializers(self)
                             self
                           end
                         end




Sunday, March 21, 2010
rails newapp --skip-activerecord




                         ActiveRecord::Railtie is not loaded




                         No AR-related config or generators
Sunday, March 21, 2010
Use Railtie to:

                    • Modify configuration/init
                    • Add Rake tasks
                    • Add generators
Sunday, March 21, 2010
Rack
                    • Deserves a talk by itself
                    • HTTP request pipeline API
                    • See Ryan Tomayko’s slides from
                         Online RailsConf

Sunday, March 21, 2010
ActiveModel




Sunday, March 21, 2010
codifies contract
                             between
                            controller
                            and model
Sunday, March 21, 2010
Contract
                         class   Model
                           def   to_model;          ...;   end
                           def   to_key;            ...;   end
                           def   to_param;          ...;   end
                           def   valid?;            ...;   end
                           def   persisted?;        ...;   end
                           def   self.model_name;   ...;   end
                           def   errors;            ...;   end
                         end



Sunday, March 21, 2010
class ModelLintTest < Test::Unit::TestCase
                    def setup
                      @model = Model.new
                    end

                    include ActiveModel::Lint::Tests
                  end




Sunday, March 21, 2010
Validations
                         class SimpleModel
                           include ActiveModel::Validations

                           # => Model#valid?, Model#errors
                           # plus validation framework
                         end




Sunday, March 21, 2010
class IceCream
                           include ActiveModel::Validations
                           attr_accessor :flavour
                           validates_presence_of :flavour
                         end

                         ic = IceCream.new
                         ic.valid? # => false
                         ic.errors.full_messages
                           # => ["Flavour can't be blank"]

                         ic.flavour = "vanilla"
                         ic.valid? # => true

Sunday, March 21, 2010
AMo Modules
                         ActiveModel::Callbacks
                           - before/after hooks
                         ActiveModel::Dirty
                           - dirty attribute tracking
                         ActiveModel::Errors
                           - #errors
                         ActiveModel::Serialization
                           - #to_xml, #to_json, etc.
                         ActiveModel::Translation
                           - I18n for model attributes
                         ActiveModel::Validations
                           - Full validations framework
      See ActiveModel RDoc comments for more info
Sunday, March 21, 2010
Putting it together



Sunday, March 21, 2010
JRuby

                         3
Sunday, March 21, 2010
Explore Rails 3
                          for yourself!


Sunday, March 21, 2010
Photo Credits
                    •    http://www.flickr.com/photos/henrybloomfield/2615837191/

                    •    http://www.flickr.com/photos/mountainbread/2528179567/

                    •    http://www.flickr.com/photos/aai/3712515230/

                    •    http://www.flickr.com/photos/mikeschinkel/2703438152/




Sunday, March 21, 2010
Sunday, March 21, 2010

More Related Content

Similar to Nick Sieger-Exploring Rails 3 Through Choices

Taming The View for Rubyconf India
Taming The View for Rubyconf IndiaTaming The View for Rubyconf India
Taming The View for Rubyconf Indiasarahtarap
 
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
 
Jquery Introduction
Jquery IntroductionJquery Introduction
Jquery Introductioncabbiepete
 
University of Abertay Dundee - afternoon
University of Abertay Dundee - afternoonUniversity of Abertay Dundee - afternoon
University of Abertay Dundee - afternoonRachel Andrew
 
CSS3: The Future is Now at Drupal Design Camp Boston
CSS3: The Future is Now at Drupal Design Camp BostonCSS3: The Future is Now at Drupal Design Camp Boston
CSS3: The Future is Now at Drupal Design Camp BostonJen Simmons
 
Creating Lifelike Designs with CSS3
Creating Lifelike Designs with CSS3Creating Lifelike Designs with CSS3
Creating Lifelike Designs with CSS3Meagan Fisher
 
University of Abertay Dundee - evening
University of Abertay Dundee - eveningUniversity of Abertay Dundee - evening
University of Abertay Dundee - eveningRachel Andrew
 
Campus Party 2010
Campus Party 2010Campus Party 2010
Campus Party 2010Fabio Akita
 
Caelum dicas web 2010
Caelum dicas web 2010Caelum dicas web 2010
Caelum dicas web 2010Fabio Akita
 
PLNOG 5: Adam Jacob - Choose your own PLNOGventure
PLNOG 5: Adam Jacob - Choose your own PLNOGventurePLNOG 5: Adam Jacob - Choose your own PLNOGventure
PLNOG 5: Adam Jacob - Choose your own PLNOGventurePROIDEA
 
12 hours to rate a rails application
12 hours to rate a rails application12 hours to rate a rails application
12 hours to rate a rails applicationehuard
 
Document-Oriented Databases: Couchdb Primer
Document-Oriented Databases: Couchdb PrimerDocument-Oriented Databases: Couchdb Primer
Document-Oriented Databases: Couchdb Primerjsiarto
 
Cutting Edge CSS3 @ WebExpo Tour 2010
Cutting Edge CSS3 @ WebExpo Tour 2010Cutting Edge CSS3 @ WebExpo Tour 2010
Cutting Edge CSS3 @ WebExpo Tour 2010Zi Bin Cheah
 
Google App Engine - Devfest India 2010
Google App Engine -  Devfest India 2010Google App Engine -  Devfest India 2010
Google App Engine - Devfest India 2010Patrick Chanezon
 
Java Server Faces 2.0 - Der Standard für moderne und komponentenbasierte Weba...
Java Server Faces 2.0 - Der Standard für moderne und komponentenbasierte Weba...Java Server Faces 2.0 - Der Standard für moderne und komponentenbasierte Weba...
Java Server Faces 2.0 - Der Standard für moderne und komponentenbasierte Weba...GFU Cyrus AG
 
Present and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola biniPresent and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola biniThoughtWorks
 
Modular gps platform 2010
Modular gps platform   2010Modular gps platform   2010
Modular gps platform 2010Osama Attia
 
12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Applicationehuard
 

Similar to Nick Sieger-Exploring Rails 3 Through Choices (20)

Taming The View for Rubyconf India
Taming The View for Rubyconf IndiaTaming The View for Rubyconf India
Taming The View for Rubyconf India
 
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
 
Jquery Introduction
Jquery IntroductionJquery Introduction
Jquery Introduction
 
University of Abertay Dundee - afternoon
University of Abertay Dundee - afternoonUniversity of Abertay Dundee - afternoon
University of Abertay Dundee - afternoon
 
CSS3: The Future is Now at Drupal Design Camp Boston
CSS3: The Future is Now at Drupal Design Camp BostonCSS3: The Future is Now at Drupal Design Camp Boston
CSS3: The Future is Now at Drupal Design Camp Boston
 
Creating Lifelike Designs with CSS3
Creating Lifelike Designs with CSS3Creating Lifelike Designs with CSS3
Creating Lifelike Designs with CSS3
 
University of Abertay Dundee - evening
University of Abertay Dundee - eveningUniversity of Abertay Dundee - evening
University of Abertay Dundee - evening
 
Campus Party 2010
Campus Party 2010Campus Party 2010
Campus Party 2010
 
Caelum dicas web 2010
Caelum dicas web 2010Caelum dicas web 2010
Caelum dicas web 2010
 
Upgrading to Rails 3
Upgrading to Rails 3Upgrading to Rails 3
Upgrading to Rails 3
 
PLNOG 5: Adam Jacob - Choose your own PLNOGventure
PLNOG 5: Adam Jacob - Choose your own PLNOGventurePLNOG 5: Adam Jacob - Choose your own PLNOGventure
PLNOG 5: Adam Jacob - Choose your own PLNOGventure
 
12 hours to rate a rails application
12 hours to rate a rails application12 hours to rate a rails application
12 hours to rate a rails application
 
Document-Oriented Databases: Couchdb Primer
Document-Oriented Databases: Couchdb PrimerDocument-Oriented Databases: Couchdb Primer
Document-Oriented Databases: Couchdb Primer
 
Cutting Edge CSS3 @ WebExpo Tour 2010
Cutting Edge CSS3 @ WebExpo Tour 2010Cutting Edge CSS3 @ WebExpo Tour 2010
Cutting Edge CSS3 @ WebExpo Tour 2010
 
Google App Engine - Devfest India 2010
Google App Engine -  Devfest India 2010Google App Engine -  Devfest India 2010
Google App Engine - Devfest India 2010
 
Java Server Faces 2.0 - Der Standard für moderne und komponentenbasierte Weba...
Java Server Faces 2.0 - Der Standard für moderne und komponentenbasierte Weba...Java Server Faces 2.0 - Der Standard für moderne und komponentenbasierte Weba...
Java Server Faces 2.0 - Der Standard für moderne und komponentenbasierte Weba...
 
Present and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola biniPresent and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola bini
 
Modular gps platform 2010
Modular gps platform   2010Modular gps platform   2010
Modular gps platform 2010
 
12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application12 Hours To Rate A Rails Application
12 Hours To Rate A Rails Application
 
What's New in GWT 2.2
What's New in GWT 2.2What's New in GWT 2.2
What's New in GWT 2.2
 

More from ThoughtWorks

Online and Publishing casestudies
Online and Publishing casestudiesOnline and Publishing casestudies
Online and Publishing casestudiesThoughtWorks
 
Insurecom Case Study
Insurecom Case StudyInsurecom Case Study
Insurecom Case StudyThoughtWorks
 
Grameen Case Study
Grameen Case StudyGrameen Case Study
Grameen Case StudyThoughtWorks
 
Construction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesConstruction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesThoughtWorks
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in RubyThoughtWorks
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in RubyThoughtWorks
 
Lets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiLets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiThoughtWorks
 
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
 Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank... Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...ThoughtWorks
 
The ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj KumarThe ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj KumarThoughtWorks
 
Ruby 124C41+ - Matz
Ruby 124C41+  - MatzRuby 124C41+  - Matz
Ruby 124C41+ - MatzThoughtWorks
 
Mac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimMac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimThoughtWorks
 
Project Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G SProject Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G SThoughtWorks
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta ThoughtWorks
 
Aman kingrubyoo pnew
Aman kingrubyoo pnew Aman kingrubyoo pnew
Aman kingrubyoo pnew ThoughtWorks
 
HadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkHadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkThoughtWorks
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone DevelopmentThoughtWorks
 
DSL Construction rith Ruby
DSL Construction rith RubyDSL Construction rith Ruby
DSL Construction rith RubyThoughtWorks
 
Transitioning To Agile Webinar Presentation
Transitioning To Agile Webinar PresentationTransitioning To Agile Webinar Presentation
Transitioning To Agile Webinar PresentationThoughtWorks
 

More from ThoughtWorks (20)

Online and Publishing casestudies
Online and Publishing casestudiesOnline and Publishing casestudies
Online and Publishing casestudies
 
Insurecom Case Study
Insurecom Case StudyInsurecom Case Study
Insurecom Case Study
 
Grameen Case Study
Grameen Case StudyGrameen Case Study
Grameen Case Study
 
BFSI Case Sudies
BFSI Case SudiesBFSI Case Sudies
BFSI Case Sudies
 
Construction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesConstruction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific Languages
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 
Lets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiLets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagi
 
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
 Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank... Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
 
The ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj KumarThe ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj Kumar
 
Ruby 124C41+ - Matz
Ruby 124C41+  - MatzRuby 124C41+  - Matz
Ruby 124C41+ - Matz
 
Mac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimMac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. Lim
 
Project Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G SProject Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G S
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta
 
Aman kingrubyoo pnew
Aman kingrubyoo pnew Aman kingrubyoo pnew
Aman kingrubyoo pnew
 
HadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkHadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software Framework
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone Development
 
DSL Construction rith Ruby
DSL Construction rith RubyDSL Construction rith Ruby
DSL Construction rith Ruby
 
Cloud Computing
Cloud  ComputingCloud  Computing
Cloud Computing
 
Transitioning To Agile Webinar Presentation
Transitioning To Agile Webinar PresentationTransitioning To Agile Webinar Presentation
Transitioning To Agile Webinar Presentation
 

Recently uploaded

[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 

Recently uploaded (20)

[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 

Nick Sieger-Exploring Rails 3 Through Choices

  • 1. Rails 3 Through Choices Nick Sieger nsieger@engineyard.com Sunday, March 21, 2010
  • 5. EY Open Source Rails JRuby Rubinius Ruby 1.8.6 Sunday, March 21, 2010
  • 10. I’m not a web developer Sunday, March 21, 2010
  • 12. HTML JSON JavaScript SQL CSS XML Ruby HTTP DNS TCP/IP Nginx Apache FCGI Memcached Sunday, March 21, 2010
  • 13. HTML JSON JavaScript SQL CSS HTTP DNS Ruby XML TCP/IP Nginx Apache FCGI Memcached Sunday, March 21, 2010
  • 15. Ruby in 2010 Sunday, March 21, 2010
  • 19. Ruby 1.8 almost seven years old! Sunday, March 21, 2010
  • 20. Ruby 1.9.2 August 2010 Sunday, March 21, 2010
  • 21. JRuby 1.5 April 2010 Sunday, March 21, 2010
  • 22. Rubinius 1.0 Q2 2010 Sunday, March 21, 2010
  • 23. Ruby 2.0 Let the prognostication begin Sunday, March 21, 2010
  • 30. paralyzed by choice Sunday, March 21, 2010
  • 34. opinionated software Sunday, March 21, 2010
  • 35. making choices Sunday, March 21, 2010
  • 37. 6 years later... Sunday, March 21, 2010
  • 41. Rails 3 highlights Sunday, March 21, 2010
  • 42. Rails command $ rails newapp create create README create .gitignore create Rakefile create config.ru create Gemfile create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/models create app/views/layouts create config ... Sunday, March 21, 2010
  • 43. Options $ rails -h Usage: rails APP_PATH [options] Options: ... -O, [--skip-activerecord] # Skip ActiveRecord files -T, [--skip-testunit] # Skip TestUnit files -J, [--skip-prototype] # Skip Prototype files Sunday, March 21, 2010
  • 44. Script script/rails s script/rails g script/server script/rails c script/generate script/console rails server rails generate rails console Sunday, March 21, 2010
  • 46. Classes class MyController < ApplicationController end class MyModel < ActiveRecord::Base end Sunday, March 21, 2010
  • 47. Unobtrusive JavaScript Sunday, March 21, 2010
  • 48. JavaScript: R2 link_to "Delete Image", @image, :confirm => "Are you sure?", :method => :delete <a href="/images/9" onclick="if (confirm('Are you sure?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild (f); f.method = 'POST'; f.action = this.href; var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild (m);f.submit(); };return false;">Delete Image</a> Sunday, March 21, 2010
  • 49. JavaScript: R3 link_to "Delete Image", @image, :confirm => "Are you sure?", :method => :delete <a href="/images/9" rel="nofollow" data-method="delete" data-confirm="Are you sure?">Delete Image</a> Sunday, March 21, 2010
  • 51. XSS Safety: R2 <%= h safe_value %> <%= unsafe_value %> Sunday, March 21, 2010
  • 52. XSS Safety: R3 <%= safe_value %> <%= raw unsafe_value %> Sunday, March 21, 2010
  • 54. Routing: R2 map.connect 'products/:id', :controller => 'catalog', :action => 'view' map.resources :products do |products| products.resources :comments products.resources :sales, :collection => { :recent => :get } end Sunday, March 21, 2010
  • 55. Routing: R3 match 'products/:id' => 'catalog#view' resources :products do resources :comments resources :sales do get :recent, :on => :collection end end Sunday, March 21, 2010
  • 56. More • Cleaner ActionMailer • ActiveRecord lazy queries • ... Sunday, March 21, 2010
  • 57. First Online RailsConf http://bit.ly/online-railsconf-slides Sunday, March 21, 2010
  • 58. APIs as Glue Sunday, March 21, 2010
  • 60. The Extension API for Rails Sunday, March 21, 2010
  • 61. Decoupling http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/ Sunday, March 21, 2010
  • 62. Decoupling http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/ ActionView ActionController ActiveRecord Sunday, March 21, 2010
  • 63. Decoupling http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/ ActionController ActionView ActiveRecord Sunday, March 21, 2010
  • 64. Decoupling http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/ ActionController ActionView ActiveRecord Sunday, March 21, 2010
  • 65. Decoupling http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/ ActionDispatch AbstractController ActionController ActionView ActiveRecord Sunday, March 21, 2010
  • 66. Decoupling http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/ ActionDispatch View AbstractController Context ActionController ActionView ActiveRecord Sunday, March 21, 2010
  • 67. Decoupling http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/ ActionDispatch View ActiveModel AbstractController Context ActionController ActionView ActiveRecord Sunday, March 21, 2010
  • 68. Encapsulate what varies Sunday, March 21, 2010
  • 69. Railties: Configuration encapsulated Sunday, March 21, 2010
  • 70. Railtie Elements Initialization Generators Rake Tasks Logging Events Sunday, March 21, 2010
  • 71. Example require 'rails/railtie' class MemCacheClusterRailtie < Rails::Railtie initializer :setup_mem_cache_cluster do |app| app.config.cache_store = [ :mem_cache_store, 'cache1:11211', 'cache2:11211'] end end Sunday, March 21, 2010
  • 72. Rails’ Railties ActionController:: ActionDispatch:: Railtie Railtie ActiveRecord:: ActionMailer:: Railtie Railtie Sunday, March 21, 2010
  • 73. Rails::Railtie Rails::Application Sunday, March 21, 2010
  • 74. Init: Rails 2 def process Rails.configuration = configuration check_ruby_version install_gem_spec_stubs set_load_path add_gem_load_paths require_frameworks set_autoload_paths add_plugin_load_paths load_environment preload_frameworks initialize_encoding initialize_database initialize_cache initialize_framework_caches initialize_logger initialize_framework_logging initialize_dependency_mechanism Sunday, March 21, 2010
  • 75. load_application_initializers # the framework is now fully initialized Init: Rails 2 after_initialize # Setup database middleware after initializers have run initialize_database_middleware # Prepare dispatcher callbacks and run 'prepare' callbacks prepare_dispatcher # Routing must be initialized after plugins to allow the former to extend the routes initialize_routing # Observers are loaded after plugins in case Observers or observed models are modified by plugins. load_observers # Load view path cache load_view_paths # Load application classes load_application_classes # Disable dependency loading during request cycle disable_dependency_loading # Flag initialized Rails.initialized = true end Sunday, March 21, 2010
  • 76. Init: Rails 3 class Rails::Application def initialize! run_initializers(self) self end end Sunday, March 21, 2010
  • 77. rails newapp --skip-activerecord ActiveRecord::Railtie is not loaded No AR-related config or generators Sunday, March 21, 2010
  • 78. Use Railtie to: • Modify configuration/init • Add Rake tasks • Add generators Sunday, March 21, 2010
  • 79. Rack • Deserves a talk by itself • HTTP request pipeline API • See Ryan Tomayko’s slides from Online RailsConf Sunday, March 21, 2010
  • 81. codifies contract between controller and model Sunday, March 21, 2010
  • 82. Contract class Model def to_model; ...; end def to_key; ...; end def to_param; ...; end def valid?; ...; end def persisted?; ...; end def self.model_name; ...; end def errors; ...; end end Sunday, March 21, 2010
  • 83. class ModelLintTest < Test::Unit::TestCase def setup @model = Model.new end include ActiveModel::Lint::Tests end Sunday, March 21, 2010
  • 84. Validations class SimpleModel include ActiveModel::Validations # => Model#valid?, Model#errors # plus validation framework end Sunday, March 21, 2010
  • 85. class IceCream include ActiveModel::Validations attr_accessor :flavour validates_presence_of :flavour end ic = IceCream.new ic.valid? # => false ic.errors.full_messages # => ["Flavour can't be blank"] ic.flavour = "vanilla" ic.valid? # => true Sunday, March 21, 2010
  • 86. AMo Modules ActiveModel::Callbacks - before/after hooks ActiveModel::Dirty - dirty attribute tracking ActiveModel::Errors - #errors ActiveModel::Serialization - #to_xml, #to_json, etc. ActiveModel::Translation - I18n for model attributes ActiveModel::Validations - Full validations framework See ActiveModel RDoc comments for more info Sunday, March 21, 2010
  • 87. Putting it together Sunday, March 21, 2010
  • 88. JRuby 3 Sunday, March 21, 2010
  • 89. Explore Rails 3 for yourself! Sunday, March 21, 2010
  • 90. Photo Credits • http://www.flickr.com/photos/henrybloomfield/2615837191/ • http://www.flickr.com/photos/mountainbread/2528179567/ • http://www.flickr.com/photos/aai/3712515230/ • http://www.flickr.com/photos/mikeschinkel/2703438152/ Sunday, March 21, 2010