upgrading to rails3
TRANSCRIPT
Upgrading to Rails 3
2010年8月18日星期三
About Me
• 鄭伊廷 a.k.a “xdite”
• http://blog.xdite.net
• http://plurk.com/xdite
• http://github.com/xdite
• Ruby on Rails Developer since 2007
• Rails Developer of HTC
2010年8月18日星期三
Rails 3
2010年8月18日星期三
http://weblog.rubyonrails.org/2008/12/23/merb-gets-merged-into-rails-3
2010年8月18日星期三
2010年8月18日星期三
It’s a big bang rewrite ...
2010年8月18日星期三
What will change?
2010年8月18日星期三
see ihower’s slide!
2010年8月18日星期三
Basis
• ActiveRecord Query API
• ActiveRecord Validation API
• View: XSS
• View: Javascript
• Routing
• Bundler
2010年8月18日星期三
Upgrade is dangerous
2010年8月18日星期三
But !
2010年8月18日星期三
台灣現在有在用 rails3 的,大概只有我跟 [*****]吧 XDXD
6/09 上午3:33:08 ihower
2010年8月18日星期三
怒字Cost: 3h4m
2010年8月18日星期三
Prerequisites
• Test Coverage
• Rails 1.8.7 and Rails 3
• RackEnv ( using Passenger )
• git remote branch
• Strong Heart and Excellent Ruby Skill.
2010年8月18日星期三
What will you face? (major)
• Query API change.
• HTML auto Escape
• Routing Changes
• Unobtrusive Javascript
• Plugin Broken ( internal API Channges )
2010年8月18日星期三
What can you do? ( major)
• use Rails Best Practice.
• writing tests
• move config.gem to Gemfile
• move rjs to unobtrusive javascripts.
• organize the same logic in HTML to helpers.
• replacing plugin to gem.
• survey plugin for rails3 ( railsplugins.org)
2010年8月18日星期三
Rails Best Practices
• Move code from Controller to Model
• Extract into Module
• Never logic code in Views
• Organize Helper files
2010年8月18日星期三
STEP
• install rails3
• modified httpd for RackEnv
• git branch rails3
• run rails-upgrade check, and document it.
• backup files ( route.rb, application.rb ... )
• rails new .
• run test, and fix. till finish......
2010年8月18日星期三
Normally, you will fail...
2010年8月18日星期三
Because...
• Not writing test (!!!)
• Writing model logic in views.(!!!)
• Post.find(:all).map{ |c| [c.name, c.id] }
• Copy & Paste anywhere(!!!)
• broken everywhere based on the same thing
• Fixing bug and refactoring project in the same time.(!!!!!!!!!!!!!)
2010年8月18日星期三
prepare well before starting
2010年8月18日星期三
Resources
• The Rails 3 Upgrade Handbook
• Bundler
• RailsPlugins.org
• The Lowdown on Routes in Rails.
• Unobtrusive Javascript in Rails 3
2010年8月18日星期三