SlideShare a Scribd company logo
With	
  a	
  Mighty	
  Hammer
bensco'ield	
  –	
  viget	
  labs
red	
  dirt	
  rubyconf
6	
  may	
  2010
Changes
Model
[rails2] > ./script/generate model Viking name:string
      exists app/models/
      exists test/unit/
      exists test/fixtures/
      create app/models/viking.rb
      create test/unit/viking_test.rb
      create test/fixtures/vikings.yml
      exists db/migrate
      create db/migrate/20100505095300_create_vikings.rb
[rails3] > rails g model Viking name:string
      invoke active_record
      create    db/migrate/20100505095405_create_vikings.rb
      create    app/models/viking.rb
      invoke    test_unit
      create      test/unit/viking_test.rb
      create      test/fixtures/vikings.yml
[rails3] > rails g model Viking name:string
      invoke active_record
      create    db/migrate/20100505095405_create_vikings.rb
      create    app/models/viking.rb
      invoke    test_unit
      create      test/unit/viking_test.rb
      create      test/fixtures/vikings.yml
Controller
[rails2] > ./script/generate controller Vikings new create
      exists app/controllers/
      exists app/helpers/
      create app/views/vikings
      exists test/functional/
      exists test/unit/helpers/
      create app/controllers/vikings_controller.rb
      create test/functional/vikings_controller_test.rb
      create app/helpers/vikings_helper.rb
      create test/unit/helpers/vikings_helper_test.rb
      create app/views/vikings/new.html.erb
      create app/views/vikings/create.html.erb
[rails3] > rails g controller Vikings new create
      create app/controllers/vikings_controller.rb
       route get "vikings/create"
       route get "vikings/new"
      invoke erb
      create    app/views/vikings
      create    app/views/vikings/new.html.erb
      create    app/views/vikings/create.html.erb
      invoke test_unit
      create    test/functional/vikings_controller_test.rb
      invoke helper
      create    app/helpers/vikings_helper.rb
      invoke    test_unit
      create      test/unit/helpers/vikings_helper_test.rb
[rails3] > rails g controller Vikings new create
      create app/controllers/vikings_controller.rb
       route get "vikings/create"
       route get "vikings/new"
      invoke erb
      create    app/views/vikings
      create    app/views/vikings/new.html.erb
      create    app/views/vikings/create.html.erb
      invoke test_unit
      create    test/functional/vikings_controller_test.rb
      invoke helper
      create    app/helpers/vikings_helper.rb
      invoke    test_unit
      create      test/unit/helpers/vikings_helper_test.rb
Resource
[rails2] > ./script/generate resource Viking name:string
      exists app/models/
      exists app/controllers/
      exists app/helpers/
      create app/views/vikings
      exists test/functional/
      exists test/unit/
      exists test/unit/helpers/
  dependency model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
      create    app/models/viking.rb
      create    test/unit/viking_test.rb
      create    test/fixtures/vikings.yml
      exists    db/migrate
      create    db/migrate/20100505095850_create_vikings.rb
      create app/controllers/vikings_controller.rb
      create test/functional/vikings_controller_test.rb
      create app/helpers/vikings_helper.rb
      create test/unit/helpers/vikings_helper_test.rb
       route map.resources :vikings
[rails3] > rails g resource Viking name:string
      invoke active_record
      create    db/migrate/20100505095729_create_vikings.rb
      create    app/models/viking.rb
      invoke    test_unit
      create      test/unit/viking_test.rb
      create      test/fixtures/vikings.yml
      invoke controller
      create    app/controllers/vikings_controller.rb
      invoke    erb
      create      app/views/vikings
      invoke    test_unit
      create      test/functional/vikings_controller_test.rb
      invoke    helper
      create      app/helpers/vikings_helper.rb
      invoke      test_unit
      create        test/unit/helpers/vikings_helper_test.rb
       route resources :vikings
[rails3] > rails g resource Viking name:string
      invoke active_record
      create    db/migrate/20100505095729_create_vikings.rb
      create    app/models/viking.rb
      invoke    test_unit
      create      test/unit/viking_test.rb
      create      test/fixtures/vikings.yml
      invoke controller
      create    app/controllers/vikings_controller.rb
      invoke    erb
      create      app/views/vikings
      invoke    test_unit
      create      test/functional/vikings_controller_test.rb
      invoke    helper
      create      app/helpers/vikings_helper.rb
      invoke      test_unit
      create        test/unit/helpers/vikings_helper_test.rb
       route resources :vikings
Options
[rails2] > ./script/generate model
Options:
         --skip-timestamps
         --skip-migration
         --skip-fixture

Rails Info:
    -v, --version
    -h, --help

General   Options:
    -p,   --pretend
    -f,   --force
    -s,   --skip
    -q,   --quiet
    -t,   --backtrace
    -c,   --svn
    -g,   --git
[rails3] > rails g model
Options:
  -o, --orm=NAME

Runtime options:
  -q, [--quiet]
  -p, [--pretend]
  -f, [--force]
  -s, [--skip]

TestUnit options:
      [--fixture]
  -r, [--fixture-replacement=NAME]

ActiveRecord options:
      [--migration]
      [--parent=PARENT]
      [--timestamps]
  -t, [--test-framework=NAME]
Additions
[rails3] > rails g model
Options:
  -o, --orm=NAME

Runtime options:
  -q, [--quiet]
  -p, [--pretend]
  -f, [--force]
  -s, [--skip]

TestUnit options:
      [--fixture]
  -r, [--fixture-replacement=NAME]

ActiveRecord options:
      [--migration]
      [--parent=PARENT]
      [--timestamps]
  -t, [--test-framework=NAME]
[rails3] > rails g resource
Options:
      [--singleton]
  -c, --resource-controller=NAME
  -o, --orm=NAME
  -a, [--actions=ACTION ACTION]
      [--force-plural]

Runtime options:
  ...

TestUnit options:
  ...

ActiveRecord options:
  ...

Controller options:
  -e, [--template-engine=NAME]
      [--helper]
  -t, [--test-framework=NAME]
Hooks
[rails3] > rails g model
Options:
  -o, --orm=NAME

Runtime options:
  ...

TestUnit options:
      [--fixture]
  -r, [--fixture-replacement=NAME]

ActiveRecord options:
      [--migration]
      [--parent=PARENT]
      [--timestamps]
  -t, [--test-framework=NAME]
[rails3] > rails g resource
Options:
      [--singleton]
  -c, --resource-controller=NAME
  -o, --orm=NAME
  -a, [--actions=ACTION ACTION]
      [--force-plural]

Runtime options:
  ...

TestUnit options:
  ...

ActiveRecord options:
  ...

Controller options:
  -e, [--template-engine=NAME]
      [--helper]
  -t, [--test-framework=NAME]
Replacements
On	
  the	
  Fly
[rails3] > rails g model Ninja name:string -o mongo_mapper

[rails3] > rails g model Ninja name:string -t shoulda

[rails3] > rails g model Ninja name:string -r factory_girl
[rails3] > rails g model Ninja name:string -o mongo_mapper
       error mongo_mapper [not found]

[rails3] > rails g model Ninja name:string -t shoulda
      invoke active_record
      create    db/migrate/20100505102902_create_ninjas.rb
      create    app/models/ninja.rb
       error    shoulda [not found]

[rails3] > rails g model Ninja name:string -r factory_girl
      invoke active_record
      create    db/migrate/20100505102902_create_ninjas.rb
      create    app/models/ninja.rb
      invoke    test_unit
      create      test/unit/ninja_test.rb
       error      factory_girl [not found]
[rails3] > rails g generator FactoryGirl
    create lib/generators/factory_girl
    create lib/generators/factory_girl/factory_girl_generator.rb
    create lib/generators/factory_girl/USAGE




                           O
    create lib/generators/factory_girl/templates




                         N
module FactoryGirl
  class ModelGenerator < Rails::Generators::NamedBase
    argument :attributes, :type => :array, :default => [],
             :banner => "field:type field:type"

    def create_fixture_file
      template 'factory.rb',
        File.join('test', 'factories', "#{singular_name}.rb")
    end

    def self.source_root
      @source_root ||= File.expand_path('../templates', __FILE__)
    end
  end
end
Factory.define :<%= singular_name %> do |f|
<% attributes.each do |attribute| -%>
<% if attribute.type == :references -%>
  f.association :<%= attribute.name %>
<% else -%>
  f.<%= attribute.name %> <%= attribute.default.inspect %>
<% end -%>
<% end -%>
end
[rails3] > rails g model Ninja name:string clan:references
           -r factory_girl
      invoke active_record
      create    db/migrate/20100505102902_create_ninjas.rb
      create    app/models/ninja.rb
      invoke    test_unit
      create      test/unit/ninja_test.rb
      invoke      factory_girl
      create        test/factories/ninja.rb
Factory.define :ninja do |f|
  f.name "MyString"
  f.association :clan
end
Changing	
  the	
  Default
module TestApp
  class Application < Rails::Application
    config.generators do |g|
      g.test_framework :test_unit,
                        :fixture_replacement => :factory_girl
    end
  end
end
[rails3] > rails g model Ninja name:string clan:references
      invoke active_record
      create    db/migrate/20100505102902_create_ninjas.rb
      create    app/models/ninja.rb
      invoke    test_unit
      create      test/unit/ninja_test.rb
      invoke      factory_girl
      create        test/factories/ninja.rb
Hooking
Typus
[rails3] > rails g resource Cowboy name:string
      invoke active_record
      create    db/migrate/20100506031815_create_cowboys.rb
      create    app/models/cowboy.rb
      invoke    test_unit
      create      test/unit/cowboy_test.rb
      invoke      factory_girl
      create        test/factories/cowboy.rb
      invoke controller
      create    app/controllers/cowboys_controller.rb
      invoke    erb
      create      app/views/cowboys
      invoke    test_unit
      create      test/functional/cowboys_controller_test.rb
      invoke    helper
      create      app/helpers/cowboys_helper.rb
      invoke      test_unit
      create        test/unit/helpers/cowboys_helper_test.rb
       route resources :cowboys
[rails3] > rails g resource Cowboy name:string
      invoke active_record
      create    db/migrate/20100506031815_create_cowboys.rb
      create    app/models/cowboy.rb
      invoke    test_unit
      create      test/unit/cowboy_test.rb
      invoke      factory_girl
      create        test/factories/cowboy.rb
      invoke controller
      create    app/controllers/cowboys_controller.rb
      invoke    erb
      create      app/views/cowboys
      invoke    test_unit
      create      test/functional/cowboys_controller_test.rb
      invoke    helper
      create      app/helpers/cowboys_helper.rb
      invoke      test_unit
      create        test/unit/helpers/cowboys_helper_test.rb
       route resources :cowboys
module Typus
  class ResourceGenerator < Rails::Generators::NamedBase
    def initialize(args, *options) #:nodoc:
      args[0] = args[0].dup if args[0].is_a?(String) &&
                               args[0].frozen?
      args[0] = "Admin::#{args[0]}"

     super
   end

   def create_controller
     template 'typus_controller.rb',
              File.join('app', 'controllers', class_path,
                        "#{file_name}_controller.rb")
   end

    hook_for :template_engine, :as => :controller
    hook_for :test_framework, :as => :controller

   # continued ...
# continued ...

    hook_for(:controller,
             :as => :controller,
             :in => :rails) do |instance, controller|
      instance.instance_eval do
        @_invocations.delete(Erb::Generators::ControllerGener...)
        @_invocations.delete(TestUnit::Generators::Controller...)
      end

      instance.invoke controller, [instance.name.demodulize]
    end

    def self.source_root
      @source_root ||= File.expand_path('../templates', __FILE__)
    end
  end
end
module TestApp
  class Application < Rails::Application
    config.generators do |g|
      g.resource_controller :typus, :controller => :controller
    end
  end
end
[rails3] > rails g resource Cowboy name:string
      invoke active_record
      create    db/migrate/20100505231238_create_cowboys.rb
      create    app/models/cowboy.rb
      invoke    test_unit
      create      test/unit/cowboy_test.rb
      invoke      factory_girl
      create        test/factories/cowboy.rb
      invoke typus
      create    app/controllers/admin/cowboys_controller.rb
      invoke    erb
      create      app/views/admin/cowboys
      invoke    test_unit
      create      test/functional/admin/cowboys_controller_test.rb
      invoke    controller
      create      app/controllers/cowboys_controller.rb
      invoke      erb
      create        app/views/cowboys
      invoke      test_unit
      create        test/functional/cowboys_controller_test.rb
      invoke      helper
      create        app/helpers/cowboys_helper.rb
      invoke        test_unit
      create          test/unit/helpers/cowboys_helper_test.rb
       route resources :cowboys
bensco'ield
@bsco'ield
ben.sco'ield@viget.com
http:/    /spkr8.com/bsco'ield
http:/    /viget.com/extend
http:	
   /bensco'ield.com
     /

More Related Content

What's hot

Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Arc & Codementor
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
Anatoly Sharifulin
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
Vance Lucas
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)
andrewnacin
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
Ryan Weaver
 
Using Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyUsing Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in Ruby
LaunchAny
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
Yusuke Wada
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
Vic Metcalfe
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
Yehuda Katz
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
diego_k
 
Lightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientLightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClient
Adam Wiggins
 
Elegant APIs
Elegant APIsElegant APIs
Elegant APIs
Andrew Timberlake
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
Tudor Constantin
 
Plugin jQuery, Design Patterns
Plugin jQuery, Design PatternsPlugin jQuery, Design Patterns
Plugin jQuery, Design Patterns
Robert Casanova
 
Mojolicious
MojoliciousMojolicious
Mojolicious
Marcos Rebelo
 
ISUCONアプリを Pythonで書いてみた
ISUCONアプリを Pythonで書いてみたISUCONアプリを Pythonで書いてみた
ISUCONアプリを Pythonで書いてみた
memememomo
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
Yehuda Katz
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
Kris Wallsmith
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
Mariusz Kozłowski
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
Marcus Ramberg
 

What's hot (20)

Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
 
Using Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyUsing Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in Ruby
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Lightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientLightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClient
 
Elegant APIs
Elegant APIsElegant APIs
Elegant APIs
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
Plugin jQuery, Design Patterns
Plugin jQuery, Design PatternsPlugin jQuery, Design Patterns
Plugin jQuery, Design Patterns
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
ISUCONアプリを Pythonで書いてみた
ISUCONアプリを Pythonで書いてみたISUCONアプリを Pythonで書いてみた
ISUCONアプリを Pythonで書いてみた
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 

Viewers also liked

Mind Control - DevNation Atlanta
Mind Control - DevNation AtlantaMind Control - DevNation Atlanta
Mind Control - DevNation Atlanta
Ben Scofield
 
Understanding Mastery
Understanding MasteryUnderstanding Mastery
Understanding Mastery
Ben Scofield
 
D E V E L O P M E N T A L P S Y C H O L O G Y A N D L E A R N I N G I B...
D E V E L O P M E N T A L  P S Y C H O L O G Y  A N D  L E A R N I N G   I  B...D E V E L O P M E N T A L  P S Y C H O L O G Y  A N D  L E A R N I N G   I  B...
D E V E L O P M E N T A L P S Y C H O L O G Y A N D L E A R N I N G I B...
Universidad Técnica Particular de Loja
 
The Future of Data
The Future of DataThe Future of Data
The Future of Data
Ben Scofield
 
Charlotte.rb - "Comics" Is Hard
Charlotte.rb - "Comics" Is HardCharlotte.rb - "Comics" Is Hard
Charlotte.rb - "Comics" Is Hard
Ben Scofield
 
Marketer Bun Sau Extraordinar
Marketer Bun Sau ExtraordinarMarketer Bun Sau Extraordinar
Marketer Bun Sau Extraordinar
Marius Sescu
 
Open Source: A Call to Arms
Open Source: A Call to ArmsOpen Source: A Call to Arms
Open Source: A Call to Arms
Ben Scofield
 
Mastery or Mediocrity
Mastery or MediocrityMastery or Mediocrity
Mastery or Mediocrity
Ben Scofield
 
Social media pentru companii - mituri si explicatii
Social media pentru companii - mituri si explicatiiSocial media pentru companii - mituri si explicatii
Social media pentru companii - mituri si explicatiiMarius Sescu
 
Thinking Small
Thinking SmallThinking Small
Thinking Small
Ben Scofield
 
Ship It
Ship ItShip It
Ship It
Ben Scofield
 
How to Be Awesome in 2.5 Steps
How to Be Awesome in 2.5 StepsHow to Be Awesome in 2.5 Steps
How to Be Awesome in 2.5 Steps
Ben Scofield
 
Intentionality: Choice and Mastery
Intentionality: Choice and MasteryIntentionality: Choice and Mastery
Intentionality: Choice and Mastery
Ben Scofield
 

Viewers also liked (13)

Mind Control - DevNation Atlanta
Mind Control - DevNation AtlantaMind Control - DevNation Atlanta
Mind Control - DevNation Atlanta
 
Understanding Mastery
Understanding MasteryUnderstanding Mastery
Understanding Mastery
 
D E V E L O P M E N T A L P S Y C H O L O G Y A N D L E A R N I N G I B...
D E V E L O P M E N T A L  P S Y C H O L O G Y  A N D  L E A R N I N G   I  B...D E V E L O P M E N T A L  P S Y C H O L O G Y  A N D  L E A R N I N G   I  B...
D E V E L O P M E N T A L P S Y C H O L O G Y A N D L E A R N I N G I B...
 
The Future of Data
The Future of DataThe Future of Data
The Future of Data
 
Charlotte.rb - "Comics" Is Hard
Charlotte.rb - "Comics" Is HardCharlotte.rb - "Comics" Is Hard
Charlotte.rb - "Comics" Is Hard
 
Marketer Bun Sau Extraordinar
Marketer Bun Sau ExtraordinarMarketer Bun Sau Extraordinar
Marketer Bun Sau Extraordinar
 
Open Source: A Call to Arms
Open Source: A Call to ArmsOpen Source: A Call to Arms
Open Source: A Call to Arms
 
Mastery or Mediocrity
Mastery or MediocrityMastery or Mediocrity
Mastery or Mediocrity
 
Social media pentru companii - mituri si explicatii
Social media pentru companii - mituri si explicatiiSocial media pentru companii - mituri si explicatii
Social media pentru companii - mituri si explicatii
 
Thinking Small
Thinking SmallThinking Small
Thinking Small
 
Ship It
Ship ItShip It
Ship It
 
How to Be Awesome in 2.5 Steps
How to Be Awesome in 2.5 StepsHow to Be Awesome in 2.5 Steps
How to Be Awesome in 2.5 Steps
 
Intentionality: Choice and Mastery
Intentionality: Choice and MasteryIntentionality: Choice and Mastery
Intentionality: Choice and Mastery
 

Similar to With a Mighty Hammer

Generators
GeneratorsGenerators
Generators
Allan Davis
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the Cloud
Hiro Asari
 
Maven iii
Maven iiiMaven iii
Maven iii
Hasan Syed
 
Maven iii
Maven iiiMaven iii
Maven iii
Sunil Komarapu
 
Building and managing java projects with maven part-III
Building and managing java projects with maven part-IIIBuilding and managing java projects with maven part-III
Building and managing java projects with maven part-III
princeirfancivil
 
Maven part 3
Maven part 3Maven part 3
Maven part 3
Mohammed246
 
Testing Legacy Rails Apps
Testing Legacy Rails AppsTesting Legacy Rails Apps
Testing Legacy Rails Apps
Rabble .
 
Innovation and Security in Ruby on Rails
Innovation and Security in Ruby on RailsInnovation and Security in Ruby on Rails
Innovation and Security in Ruby on Rails
tielefeld
 
Redmine Betabeers SVQ
Redmine Betabeers SVQRedmine Betabeers SVQ
Redmine Betabeers SVQ
Ildefonso Montero
 
What's new in Django 1.2?
What's new in Django 1.2?What's new in Django 1.2?
What's new in Django 1.2?
Jacob Kaplan-Moss
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
Nikhil Mungel
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
Michał Orman
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
Robert Gogolok
 
前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo
Michael Zhang
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third Plugin
Justin Ryan
 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthrough
Sangwon Lee
 
Django tricks (2)
Django tricks (2)Django tricks (2)
Django tricks (2)
Carlos Hernando
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
Fabio Akita
 
What's new in Rails 4
What's new in Rails 4What's new in Rails 4
What's new in Rails 4
Fabio Akita
 
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Conference
 

Similar to With a Mighty Hammer (20)

Generators
GeneratorsGenerators
Generators
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the Cloud
 
Maven iii
Maven iiiMaven iii
Maven iii
 
Maven iii
Maven iiiMaven iii
Maven iii
 
Building and managing java projects with maven part-III
Building and managing java projects with maven part-IIIBuilding and managing java projects with maven part-III
Building and managing java projects with maven part-III
 
Maven part 3
Maven part 3Maven part 3
Maven part 3
 
Testing Legacy Rails Apps
Testing Legacy Rails AppsTesting Legacy Rails Apps
Testing Legacy Rails Apps
 
Innovation and Security in Ruby on Rails
Innovation and Security in Ruby on RailsInnovation and Security in Ruby on Rails
Innovation and Security in Ruby on Rails
 
Redmine Betabeers SVQ
Redmine Betabeers SVQRedmine Betabeers SVQ
Redmine Betabeers SVQ
 
What's new in Django 1.2?
What's new in Django 1.2?What's new in Django 1.2?
What's new in Django 1.2?
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third Plugin
 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthrough
 
Django tricks (2)
Django tricks (2)Django tricks (2)
Django tricks (2)
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
 
What's new in Rails 4
What's new in Rails 4What's new in Rails 4
What's new in Rails 4
 
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
 

More from Ben Scofield

Mind Control: Psychology for the Web
Mind Control: Psychology for the WebMind Control: Psychology for the Web
Mind Control: Psychology for the Web
Ben Scofield
 
The State of NoSQL
The State of NoSQLThe State of NoSQL
The State of NoSQL
Ben Scofield
 
NoSQL @ CodeMash 2010
NoSQL @ CodeMash 2010NoSQL @ CodeMash 2010
NoSQL @ CodeMash 2010
Ben Scofield
 
NoSQL: Death to Relational Databases(?)
NoSQL: Death to Relational Databases(?)NoSQL: Death to Relational Databases(?)
NoSQL: Death to Relational Databases(?)
Ben Scofield
 
WindyCityRails - "Comics" Is Hard
WindyCityRails - "Comics" Is HardWindyCityRails - "Comics" Is Hard
WindyCityRails - "Comics" Is Hard
Ben Scofield
 
"Comics" Is Hard: Alternative Databases
"Comics" Is Hard: Alternative Databases"Comics" Is Hard: Alternative Databases
"Comics" Is Hard: Alternative Databases
Ben Scofield
 
Mind Control on the Web
Mind Control on the WebMind Control on the Web
Mind Control on the Web
Ben Scofield
 
How the Geeks Inherited the Earth
How the Geeks Inherited the EarthHow the Geeks Inherited the Earth
How the Geeks Inherited the Earth
Ben Scofield
 
And the Greatest of These Is ... Space
And the Greatest of These Is ... SpaceAnd the Greatest of These Is ... Space
And the Greatest of These Is ... Space
Ben Scofield
 
"Comics" Is Hard: Domain Modeling Challenges
"Comics" Is Hard: Domain Modeling Challenges"Comics" Is Hard: Domain Modeling Challenges
"Comics" Is Hard: Domain Modeling Challenges
Ben Scofield
 
And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack Support
Ben Scofield
 
Page Caching Resurrected
Page Caching ResurrectedPage Caching Resurrected
Page Caching Resurrected
Ben Scofield
 
Page Caching Resurrected: A Fairy Tale
Page Caching Resurrected: A Fairy TalePage Caching Resurrected: A Fairy Tale
Page Caching Resurrected: A Fairy Tale
Ben Scofield
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
Ben Scofield
 
Advanced Restful Rails - Europe
Advanced Restful Rails - EuropeAdvanced Restful Rails - Europe
Advanced Restful Rails - Europe
Ben Scofield
 
Resourceful Plugins
Resourceful PluginsResourceful Plugins
Resourceful Plugins
Ben Scofield
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
Ben Scofield
 

More from Ben Scofield (17)

Mind Control: Psychology for the Web
Mind Control: Psychology for the WebMind Control: Psychology for the Web
Mind Control: Psychology for the Web
 
The State of NoSQL
The State of NoSQLThe State of NoSQL
The State of NoSQL
 
NoSQL @ CodeMash 2010
NoSQL @ CodeMash 2010NoSQL @ CodeMash 2010
NoSQL @ CodeMash 2010
 
NoSQL: Death to Relational Databases(?)
NoSQL: Death to Relational Databases(?)NoSQL: Death to Relational Databases(?)
NoSQL: Death to Relational Databases(?)
 
WindyCityRails - "Comics" Is Hard
WindyCityRails - "Comics" Is HardWindyCityRails - "Comics" Is Hard
WindyCityRails - "Comics" Is Hard
 
"Comics" Is Hard: Alternative Databases
"Comics" Is Hard: Alternative Databases"Comics" Is Hard: Alternative Databases
"Comics" Is Hard: Alternative Databases
 
Mind Control on the Web
Mind Control on the WebMind Control on the Web
Mind Control on the Web
 
How the Geeks Inherited the Earth
How the Geeks Inherited the EarthHow the Geeks Inherited the Earth
How the Geeks Inherited the Earth
 
And the Greatest of These Is ... Space
And the Greatest of These Is ... SpaceAnd the Greatest of These Is ... Space
And the Greatest of These Is ... Space
 
"Comics" Is Hard: Domain Modeling Challenges
"Comics" Is Hard: Domain Modeling Challenges"Comics" Is Hard: Domain Modeling Challenges
"Comics" Is Hard: Domain Modeling Challenges
 
And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack Support
 
Page Caching Resurrected
Page Caching ResurrectedPage Caching Resurrected
Page Caching Resurrected
 
Page Caching Resurrected: A Fairy Tale
Page Caching Resurrected: A Fairy TalePage Caching Resurrected: A Fairy Tale
Page Caching Resurrected: A Fairy Tale
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Advanced Restful Rails - Europe
Advanced Restful Rails - EuropeAdvanced Restful Rails - Europe
Advanced Restful Rails - Europe
 
Resourceful Plugins
Resourceful PluginsResourceful Plugins
Resourceful Plugins
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 

Recently uploaded

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 

Recently uploaded (20)

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 

With a Mighty Hammer

  • 1. With  a  Mighty  Hammer bensco'ield  –  viget  labs red  dirt  rubyconf 6  may  2010
  • 4. [rails2] > ./script/generate model Viking name:string exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/viking.rb create test/unit/viking_test.rb create test/fixtures/vikings.yml exists db/migrate create db/migrate/20100505095300_create_vikings.rb
  • 5. [rails3] > rails g model Viking name:string invoke active_record create db/migrate/20100505095405_create_vikings.rb create app/models/viking.rb invoke test_unit create test/unit/viking_test.rb create test/fixtures/vikings.yml
  • 6. [rails3] > rails g model Viking name:string invoke active_record create db/migrate/20100505095405_create_vikings.rb create app/models/viking.rb invoke test_unit create test/unit/viking_test.rb create test/fixtures/vikings.yml
  • 8. [rails2] > ./script/generate controller Vikings new create exists app/controllers/ exists app/helpers/ create app/views/vikings exists test/functional/ exists test/unit/helpers/ create app/controllers/vikings_controller.rb create test/functional/vikings_controller_test.rb create app/helpers/vikings_helper.rb create test/unit/helpers/vikings_helper_test.rb create app/views/vikings/new.html.erb create app/views/vikings/create.html.erb
  • 9. [rails3] > rails g controller Vikings new create create app/controllers/vikings_controller.rb route get "vikings/create" route get "vikings/new" invoke erb create app/views/vikings create app/views/vikings/new.html.erb create app/views/vikings/create.html.erb invoke test_unit create test/functional/vikings_controller_test.rb invoke helper create app/helpers/vikings_helper.rb invoke test_unit create test/unit/helpers/vikings_helper_test.rb
  • 10. [rails3] > rails g controller Vikings new create create app/controllers/vikings_controller.rb route get "vikings/create" route get "vikings/new" invoke erb create app/views/vikings create app/views/vikings/new.html.erb create app/views/vikings/create.html.erb invoke test_unit create test/functional/vikings_controller_test.rb invoke helper create app/helpers/vikings_helper.rb invoke test_unit create test/unit/helpers/vikings_helper_test.rb
  • 12. [rails2] > ./script/generate resource Viking name:string exists app/models/ exists app/controllers/ exists app/helpers/ create app/views/vikings exists test/functional/ exists test/unit/ exists test/unit/helpers/ dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/viking.rb create test/unit/viking_test.rb create test/fixtures/vikings.yml exists db/migrate create db/migrate/20100505095850_create_vikings.rb create app/controllers/vikings_controller.rb create test/functional/vikings_controller_test.rb create app/helpers/vikings_helper.rb create test/unit/helpers/vikings_helper_test.rb route map.resources :vikings
  • 13. [rails3] > rails g resource Viking name:string invoke active_record create db/migrate/20100505095729_create_vikings.rb create app/models/viking.rb invoke test_unit create test/unit/viking_test.rb create test/fixtures/vikings.yml invoke controller create app/controllers/vikings_controller.rb invoke erb create app/views/vikings invoke test_unit create test/functional/vikings_controller_test.rb invoke helper create app/helpers/vikings_helper.rb invoke test_unit create test/unit/helpers/vikings_helper_test.rb route resources :vikings
  • 14. [rails3] > rails g resource Viking name:string invoke active_record create db/migrate/20100505095729_create_vikings.rb create app/models/viking.rb invoke test_unit create test/unit/viking_test.rb create test/fixtures/vikings.yml invoke controller create app/controllers/vikings_controller.rb invoke erb create app/views/vikings invoke test_unit create test/functional/vikings_controller_test.rb invoke helper create app/helpers/vikings_helper.rb invoke test_unit create test/unit/helpers/vikings_helper_test.rb route resources :vikings
  • 16. [rails2] > ./script/generate model Options: --skip-timestamps --skip-migration --skip-fixture Rails Info: -v, --version -h, --help General Options: -p, --pretend -f, --force -s, --skip -q, --quiet -t, --backtrace -c, --svn -g, --git
  • 17. [rails3] > rails g model Options: -o, --orm=NAME Runtime options: -q, [--quiet] -p, [--pretend] -f, [--force] -s, [--skip] TestUnit options: [--fixture] -r, [--fixture-replacement=NAME] ActiveRecord options: [--migration] [--parent=PARENT] [--timestamps] -t, [--test-framework=NAME]
  • 19. [rails3] > rails g model Options: -o, --orm=NAME Runtime options: -q, [--quiet] -p, [--pretend] -f, [--force] -s, [--skip] TestUnit options: [--fixture] -r, [--fixture-replacement=NAME] ActiveRecord options: [--migration] [--parent=PARENT] [--timestamps] -t, [--test-framework=NAME]
  • 20. [rails3] > rails g resource Options: [--singleton] -c, --resource-controller=NAME -o, --orm=NAME -a, [--actions=ACTION ACTION] [--force-plural] Runtime options: ... TestUnit options: ... ActiveRecord options: ... Controller options: -e, [--template-engine=NAME] [--helper] -t, [--test-framework=NAME]
  • 21. Hooks
  • 22. [rails3] > rails g model Options: -o, --orm=NAME Runtime options: ... TestUnit options: [--fixture] -r, [--fixture-replacement=NAME] ActiveRecord options: [--migration] [--parent=PARENT] [--timestamps] -t, [--test-framework=NAME]
  • 23. [rails3] > rails g resource Options: [--singleton] -c, --resource-controller=NAME -o, --orm=NAME -a, [--actions=ACTION ACTION] [--force-plural] Runtime options: ... TestUnit options: ... ActiveRecord options: ... Controller options: -e, [--template-engine=NAME] [--helper] -t, [--test-framework=NAME]
  • 26. [rails3] > rails g model Ninja name:string -o mongo_mapper [rails3] > rails g model Ninja name:string -t shoulda [rails3] > rails g model Ninja name:string -r factory_girl
  • 27. [rails3] > rails g model Ninja name:string -o mongo_mapper error mongo_mapper [not found] [rails3] > rails g model Ninja name:string -t shoulda invoke active_record create db/migrate/20100505102902_create_ninjas.rb create app/models/ninja.rb error shoulda [not found] [rails3] > rails g model Ninja name:string -r factory_girl invoke active_record create db/migrate/20100505102902_create_ninjas.rb create app/models/ninja.rb invoke test_unit create test/unit/ninja_test.rb error factory_girl [not found]
  • 28. [rails3] > rails g generator FactoryGirl create lib/generators/factory_girl create lib/generators/factory_girl/factory_girl_generator.rb create lib/generators/factory_girl/USAGE O create lib/generators/factory_girl/templates N
  • 29.
  • 30. module FactoryGirl class ModelGenerator < Rails::Generators::NamedBase argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" def create_fixture_file template 'factory.rb', File.join('test', 'factories', "#{singular_name}.rb") end def self.source_root @source_root ||= File.expand_path('../templates', __FILE__) end end end
  • 31. Factory.define :<%= singular_name %> do |f| <% attributes.each do |attribute| -%> <% if attribute.type == :references -%> f.association :<%= attribute.name %> <% else -%> f.<%= attribute.name %> <%= attribute.default.inspect %> <% end -%> <% end -%> end
  • 32. [rails3] > rails g model Ninja name:string clan:references -r factory_girl invoke active_record create db/migrate/20100505102902_create_ninjas.rb create app/models/ninja.rb invoke test_unit create test/unit/ninja_test.rb invoke factory_girl create test/factories/ninja.rb
  • 33. Factory.define :ninja do |f| f.name "MyString" f.association :clan end
  • 35. module TestApp class Application < Rails::Application config.generators do |g| g.test_framework :test_unit, :fixture_replacement => :factory_girl end end end
  • 36. [rails3] > rails g model Ninja name:string clan:references invoke active_record create db/migrate/20100505102902_create_ninjas.rb create app/models/ninja.rb invoke test_unit create test/unit/ninja_test.rb invoke factory_girl create test/factories/ninja.rb
  • 38. Typus
  • 39.
  • 40. [rails3] > rails g resource Cowboy name:string invoke active_record create db/migrate/20100506031815_create_cowboys.rb create app/models/cowboy.rb invoke test_unit create test/unit/cowboy_test.rb invoke factory_girl create test/factories/cowboy.rb invoke controller create app/controllers/cowboys_controller.rb invoke erb create app/views/cowboys invoke test_unit create test/functional/cowboys_controller_test.rb invoke helper create app/helpers/cowboys_helper.rb invoke test_unit create test/unit/helpers/cowboys_helper_test.rb route resources :cowboys
  • 41. [rails3] > rails g resource Cowboy name:string invoke active_record create db/migrate/20100506031815_create_cowboys.rb create app/models/cowboy.rb invoke test_unit create test/unit/cowboy_test.rb invoke factory_girl create test/factories/cowboy.rb invoke controller create app/controllers/cowboys_controller.rb invoke erb create app/views/cowboys invoke test_unit create test/functional/cowboys_controller_test.rb invoke helper create app/helpers/cowboys_helper.rb invoke test_unit create test/unit/helpers/cowboys_helper_test.rb route resources :cowboys
  • 42. module Typus class ResourceGenerator < Rails::Generators::NamedBase def initialize(args, *options) #:nodoc: args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen? args[0] = "Admin::#{args[0]}" super end def create_controller template 'typus_controller.rb', File.join('app', 'controllers', class_path, "#{file_name}_controller.rb") end hook_for :template_engine, :as => :controller hook_for :test_framework, :as => :controller # continued ...
  • 43. # continued ... hook_for(:controller, :as => :controller, :in => :rails) do |instance, controller| instance.instance_eval do @_invocations.delete(Erb::Generators::ControllerGener...) @_invocations.delete(TestUnit::Generators::Controller...) end instance.invoke controller, [instance.name.demodulize] end def self.source_root @source_root ||= File.expand_path('../templates', __FILE__) end end end
  • 44. module TestApp class Application < Rails::Application config.generators do |g| g.resource_controller :typus, :controller => :controller end end end
  • 45. [rails3] > rails g resource Cowboy name:string invoke active_record create db/migrate/20100505231238_create_cowboys.rb create app/models/cowboy.rb invoke test_unit create test/unit/cowboy_test.rb invoke factory_girl create test/factories/cowboy.rb invoke typus create app/controllers/admin/cowboys_controller.rb invoke erb create app/views/admin/cowboys invoke test_unit create test/functional/admin/cowboys_controller_test.rb invoke controller create app/controllers/cowboys_controller.rb invoke erb create app/views/cowboys invoke test_unit create test/functional/cowboys_controller_test.rb invoke helper create app/helpers/cowboys_helper.rb invoke test_unit create test/unit/helpers/cowboys_helper_test.rb route resources :cowboys
  • 46.
  • 47. bensco'ield @bsco'ield ben.sco'ield@viget.com http:/ /spkr8.com/bsco'ield http:/ /viget.com/extend http:   /bensco'ield.com /