SlideShare una empresa de Scribd logo
Rails 3 app auto-generator
            Tse-Ching Ho
      2010/08/17 Ruby-Tuesday | ruby.tw
It’s bored to always write
      the same codes.
Who needs auto generator?
NO, Rails Newbies!!
Before you do it,

You must understand what you are doing.

You should play on local branch (git/mercurial).

You should know each pieces of codes (Don’t generate trash).

You need consistency between projects.

You want be a time saver (Stop copy, paste and verify).

You type codes as slow as me :(
What should we do?
Modulate your codes


Maintainability is a critical thing for long life projects.

Reusability is valuable for programmers.

Modules are everywhere in rails 3. Use it!
Gemify your modules
Be a ruby gem producer
http://railscasts.com/episodes/218-making-generators-in-rails-3

jeweler --rspec --gemcutter my_awesome_gem

bundle gem my_awesome_gem

   create my_awesome_gem/Gemfile
   create my_awesome_gem/Rakefile
   create my_awesome_gem/.gitignore
   create my_awesome_gem/my_awesome_gem.gemspec
   create my_awesome_gem/lib/my_awesome_gem.rb
   create my_awesome_gem/lib/my_awesome_gem/version.rb

   rake build
   rake install
   rake push
Update to Rails 3

Be familiar with APIs of thor and rails 3 generator
  gsub_file 'public/stylesheets/blueprint/screen.css', /src/grid.png/, 'grid.png'

  inject_into_file 'config/application.rb', "n   config.middleware.use Rack::Tidyn", :before => " end
  nendn"


Keep updated by force/skip overwrite option
  rails generate responders:install -f
Live Demo
Issues
Bundler
Gemfile.lock should always keep updated in generators.

  gem 'simple_form'
  run 'bundle install'
  run 'bundle update'
  generate 'simple_form:install', '-s'

Use gems, don’t use git branch.

You should commit Gemfile.lock if you need consistency
between development and production environment.
JQuery

get 'http://github.com/rails/jquery-ujs/raw/master/src/rails.js', 'public/
javascripts/rails.js'

inject_into_file 'config/application.rb', "
config.action_view.javascript_expansions[:defaults] = %w(jquery jquery-ui rails)
n", :after => "# config.action_view.javascript_expansions[:defaults] = %w(jquery
rails)n", :verbose => false

jqueryui.com only keeps the latest one zip file!

   http://jqueryui.com/download/jquery-ui-1.8.4.custom.zip
Customized templates
Rails.root/lib/templates/erb/scaffold/index.html.erb

config.generators.scaffold_controller = :responders_controller

config.generators do |g|
  g.orm              :active_record
  g.template_engine :erb
  g.integration_tool :rspec
  g.test_framework :rspec
  g.scaffold         :stylesheets => false
end
Migration files
migration_template 'create_roles.rb', 'db/migrate/create_roles.rb'

# Implement the required interface for Rails::Generators::Migration.
def self.next_migration_number(dirname) #:nodoc:
  @next_migration_number = if @next_migration_number
      (@next_migration_number.to_i + 1).to_s
  elsif ActiveRecord::Base.timestamped_migrations
      Time.now.utc.strftime("%Y%m%d%H%M%S")
  else
      "%.3d" % (current_migration_number(dirname) + 1)
  end
end
def migration_template(source, destination=nil, config={})
  super
rescue Rails::Generators::Error => e
  puts e
end
What else?

File.exist?

File path

  source_root

  destination_root

  Rails.root

Customized configuration files (config/xxx.rb)
Make every practices as
      generator!
Q&A
About me


       Tse-Ching Ho (http://github.com/tsechingho)

Use Rails 2 since 2008

Senior R&D programmer in techbang.tw (T     ) now
- END -

Más contenido relacionado

La actualidad más candente

The Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsThe Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web apps
John Anderson
 
Frontend Finesse with Angular & Rails 4
Frontend Finesse with Angular & Rails 4Frontend Finesse with Angular & Rails 4
Frontend Finesse with Angular & Rails 4
undecisive
 

La actualidad más candente (20)

Engines
EnginesEngines
Engines
 
Up & running with ECMAScript6
Up & running with ECMAScript6Up & running with ECMAScript6
Up & running with ECMAScript6
 
I motion
I motionI motion
I motion
 
Ansible -new kid in configuration management world
Ansible -new kid in configuration management worldAnsible -new kid in configuration management world
Ansible -new kid in configuration management world
 
MVC-RS par Grégoire Lhotelier
MVC-RS par Grégoire LhotelierMVC-RS par Grégoire Lhotelier
MVC-RS par Grégoire Lhotelier
 
javascript for backend developers
javascript for backend developersjavascript for backend developers
javascript for backend developers
 
AngularJS performance & production tips
AngularJS performance & production tipsAngularJS performance & production tips
AngularJS performance & production tips
 
A little respect for MVC part 1 par Gegoire Lhotellier
A little respect for MVC part 1 par Gegoire LhotellierA little respect for MVC part 1 par Gegoire Lhotellier
A little respect for MVC part 1 par Gegoire Lhotellier
 
What's New in JHipsterLand - Devoxx Poland 2017
What's New in JHipsterLand - Devoxx Poland 2017What's New in JHipsterLand - Devoxx Poland 2017
What's New in JHipsterLand - Devoxx Poland 2017
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 
Intro to UI-Router/TypeScript
Intro to UI-Router/TypeScriptIntro to UI-Router/TypeScript
Intro to UI-Router/TypeScript
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love Ruby
 
Performance monitoring measurement angualrjs single page apps with phantomas
Performance monitoring measurement angualrjs single page apps with phantomasPerformance monitoring measurement angualrjs single page apps with phantomas
Performance monitoring measurement angualrjs single page apps with phantomas
 
React for Developers
React for DevelopersReact for Developers
React for Developers
 
React‌ برای دولوپرها
React‌ برای دولوپرهاReact‌ برای دولوپرها
React‌ برای دولوپرها
 
The Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsThe Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web apps
 
Future of Web Development
Future of Web DevelopmentFuture of Web Development
Future of Web Development
 
Bootiful Development with Spring Boot and Angular - Spring I/O 2017
Bootiful Development with Spring Boot and Angular - Spring I/O 2017Bootiful Development with Spring Boot and Angular - Spring I/O 2017
Bootiful Development with Spring Boot and Angular - Spring I/O 2017
 
Frontend Finesse with Angular & Rails 4
Frontend Finesse with Angular & Rails 4Frontend Finesse with Angular & Rails 4
Frontend Finesse with Angular & Rails 4
 
Sinatra
SinatraSinatra
Sinatra
 

Destacado

Downloading Books from BARD for Your Digital Player
Downloading Books from BARD for Your Digital PlayerDownloading Books from BARD for Your Digital Player
Downloading Books from BARD for Your Digital Player
Nathan Flinchum
 
PHP Deployment With Capistrano
PHP Deployment With CapistranoPHP Deployment With Capistrano
PHP Deployment With Capistrano
jserpieters
 
Pillars.io wake upstartup
Pillars.io wake upstartupPillars.io wake upstartup
Pillars.io wake upstartup
Brian Link
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_tw
Tse-Ching Ho
 
Ponencia PROFECO CENHIES
Ponencia PROFECO CENHIESPonencia PROFECO CENHIES
Ponencia PROFECO CENHIES
Emmanuel Ameth
 
Gótika 2012 19_berry
Gótika 2012 19_berryGótika 2012 19_berry
Gótika 2012 19_berry
eorsianna
 
Tema 2. Conocimiento
Tema 2. ConocimientoTema 2. Conocimiento
Tema 2. Conocimiento
Carlos-9
 
Excursió a can joan
Excursió a can joanExcursió a can joan
Excursió a can joan
magefra
 
La prehistoria
La prehistoriaLa prehistoria
La prehistoria
noeliask
 
Peras 091015103737-phpapp01
Peras 091015103737-phpapp01Peras 091015103737-phpapp01
Peras 091015103737-phpapp01
04141998
 
Preliminary Task Storyboard
Preliminary Task StoryboardPreliminary Task Storyboard
Preliminary Task Storyboard
HannahCostello
 
Estadisticas de los pueblos
Estadisticas de los pueblosEstadisticas de los pueblos
Estadisticas de los pueblos
rubenm18
 

Destacado (20)

D40 16p
D40 16pD40 16p
D40 16p
 
We Were All N00bs: Learning the Social Web by Using the Social Web
We Were All N00bs: Learning the Social Web by Using the Social WebWe Were All N00bs: Learning the Social Web by Using the Social Web
We Were All N00bs: Learning the Social Web by Using the Social Web
 
Downloading Books from BARD for Your Digital Player
Downloading Books from BARD for Your Digital PlayerDownloading Books from BARD for Your Digital Player
Downloading Books from BARD for Your Digital Player
 
Puruchuco
PuruchucoPuruchuco
Puruchuco
 
PHP Deployment With Capistrano
PHP Deployment With CapistranoPHP Deployment With Capistrano
PHP Deployment With Capistrano
 
Get Hip Libraries And Gangsta Lit
Get Hip   Libraries And Gangsta LitGet Hip   Libraries And Gangsta Lit
Get Hip Libraries And Gangsta Lit
 
ruby e-commerce
ruby e-commerceruby e-commerce
ruby e-commerce
 
Staff Training the Wiki Wacky Way!
Staff Training the Wiki Wacky Way!Staff Training the Wiki Wacky Way!
Staff Training the Wiki Wacky Way!
 
Pillars.io wake upstartup
Pillars.io wake upstartupPillars.io wake upstartup
Pillars.io wake upstartup
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_tw
 
Ruby on bioinformatics
Ruby on bioinformaticsRuby on bioinformatics
Ruby on bioinformatics
 
Building Great Software Engineering Teams
Building Great Software Engineering TeamsBuilding Great Software Engineering Teams
Building Great Software Engineering Teams
 
Ponencia PROFECO CENHIES
Ponencia PROFECO CENHIESPonencia PROFECO CENHIES
Ponencia PROFECO CENHIES
 
Gótika 2012 19_berry
Gótika 2012 19_berryGótika 2012 19_berry
Gótika 2012 19_berry
 
Tema 2. Conocimiento
Tema 2. ConocimientoTema 2. Conocimiento
Tema 2. Conocimiento
 
Excursió a can joan
Excursió a can joanExcursió a can joan
Excursió a can joan
 
La prehistoria
La prehistoriaLa prehistoria
La prehistoria
 
Peras 091015103737-phpapp01
Peras 091015103737-phpapp01Peras 091015103737-phpapp01
Peras 091015103737-phpapp01
 
Preliminary Task Storyboard
Preliminary Task StoryboardPreliminary Task Storyboard
Preliminary Task Storyboard
 
Estadisticas de los pueblos
Estadisticas de los pueblosEstadisticas de los pueblos
Estadisticas de los pueblos
 

Similar a Rails-3-app-auto-generator-20100817

Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
Spike Brehm
 
JRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell YouJRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell You
elliando dias
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3
Clinton Dreisbach
 
Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
dswork
 

Similar a Rails-3-app-auto-generator-20100817 (20)

Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
 
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
 
Monkeybars in the Manor
Monkeybars in the ManorMonkeybars in the Manor
Monkeybars in the Manor
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular application
 
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!
 
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
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
 
Angular JS in 2017
Angular JS in 2017Angular JS in 2017
Angular JS in 2017
 
20141210 rakuten techtalk
20141210 rakuten techtalk20141210 rakuten techtalk
20141210 rakuten techtalk
 
JRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell YouJRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell You
 
Derailing rails
Derailing railsDerailing rails
Derailing rails
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3
 
Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraform
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
 
Damage Control
Damage ControlDamage Control
Damage Control
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 

Más de Tse-Ching Ho (6)

Webconf2013
Webconf2013Webconf2013
Webconf2013
 
Ajax nested form and ajax upload in rails
Ajax nested form and ajax upload in railsAjax nested form and ajax upload in rails
Ajax nested form and ajax upload in rails
 
mongodb-introduction
mongodb-introductionmongodb-introduction
mongodb-introduction
 
devise tutorial - 2011 rubyconf taiwan
devise tutorial - 2011 rubyconf taiwandevise tutorial - 2011 rubyconf taiwan
devise tutorial - 2011 rubyconf taiwan
 
model.search: customize your own search logic
model.search: customize your own search logicmodel.search: customize your own search logic
model.search: customize your own search logic
 
The Power of Rails 2.3 Engines & Templates
The Power of Rails 2.3 Engines & TemplatesThe Power of Rails 2.3 Engines & Templates
The Power of Rails 2.3 Engines & Templates
 

Último

Último (20)

UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 

Rails-3-app-auto-generator-20100817

  • 1. Rails 3 app auto-generator Tse-Ching Ho 2010/08/17 Ruby-Tuesday | ruby.tw
  • 2. It’s bored to always write the same codes.
  • 3. Who needs auto generator?
  • 4. NO, Rails Newbies!! Before you do it, You must understand what you are doing. You should play on local branch (git/mercurial). You should know each pieces of codes (Don’t generate trash). You need consistency between projects. You want be a time saver (Stop copy, paste and verify). You type codes as slow as me :(
  • 6. Modulate your codes Maintainability is a critical thing for long life projects. Reusability is valuable for programmers. Modules are everywhere in rails 3. Use it!
  • 7. Gemify your modules Be a ruby gem producer http://railscasts.com/episodes/218-making-generators-in-rails-3 jeweler --rspec --gemcutter my_awesome_gem bundle gem my_awesome_gem create my_awesome_gem/Gemfile create my_awesome_gem/Rakefile create my_awesome_gem/.gitignore create my_awesome_gem/my_awesome_gem.gemspec create my_awesome_gem/lib/my_awesome_gem.rb create my_awesome_gem/lib/my_awesome_gem/version.rb rake build rake install rake push
  • 8. Update to Rails 3 Be familiar with APIs of thor and rails 3 generator gsub_file 'public/stylesheets/blueprint/screen.css', /src/grid.png/, 'grid.png' inject_into_file 'config/application.rb', "n config.middleware.use Rack::Tidyn", :before => " end nendn" Keep updated by force/skip overwrite option rails generate responders:install -f
  • 11. Bundler Gemfile.lock should always keep updated in generators. gem 'simple_form' run 'bundle install' run 'bundle update' generate 'simple_form:install', '-s' Use gems, don’t use git branch. You should commit Gemfile.lock if you need consistency between development and production environment.
  • 12. JQuery get 'http://github.com/rails/jquery-ujs/raw/master/src/rails.js', 'public/ javascripts/rails.js' inject_into_file 'config/application.rb', " config.action_view.javascript_expansions[:defaults] = %w(jquery jquery-ui rails) n", :after => "# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)n", :verbose => false jqueryui.com only keeps the latest one zip file! http://jqueryui.com/download/jquery-ui-1.8.4.custom.zip
  • 13. Customized templates Rails.root/lib/templates/erb/scaffold/index.html.erb config.generators.scaffold_controller = :responders_controller config.generators do |g| g.orm :active_record g.template_engine :erb g.integration_tool :rspec g.test_framework :rspec g.scaffold :stylesheets => false end
  • 14. Migration files migration_template 'create_roles.rb', 'db/migrate/create_roles.rb' # Implement the required interface for Rails::Generators::Migration. def self.next_migration_number(dirname) #:nodoc: @next_migration_number = if @next_migration_number (@next_migration_number.to_i + 1).to_s elsif ActiveRecord::Base.timestamped_migrations Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end def migration_template(source, destination=nil, config={}) super rescue Rails::Generators::Error => e puts e end
  • 15. What else? File.exist? File path source_root destination_root Rails.root Customized configuration files (config/xxx.rb)
  • 16. Make every practices as generator!
  • 17. Q&A
  • 18. About me Tse-Ching Ho (http://github.com/tsechingho) Use Rails 2 since 2008 Senior R&D programmer in techbang.tw (T ) now