upgrading to rails3

23
Upgrading to Rails 3 2010年8月18日星期三

Upload: yi-ting-cheng

Post on 10-May-2015

1.773 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Upgrading to rails3

Upgrading to Rails 3

2010年8月18日星期三

Page 2: Upgrading to rails3

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日星期三

Page 3: Upgrading to rails3

Rails 3

2010年8月18日星期三

Page 4: Upgrading to rails3

http://weblog.rubyonrails.org/2008/12/23/merb-gets-merged-into-rails-3

2010年8月18日星期三

Page 5: Upgrading to rails3

2010年8月18日星期三

Page 6: Upgrading to rails3

It’s a big bang rewrite ...

2010年8月18日星期三

Page 7: Upgrading to rails3

What will change?

2010年8月18日星期三

Page 8: Upgrading to rails3

see ihower’s slide!

2010年8月18日星期三

Page 9: Upgrading to rails3

Basis

• ActiveRecord Query API

• ActiveRecord Validation API

• View: XSS

• View: Javascript

• Routing

• Bundler

2010年8月18日星期三

Page 10: Upgrading to rails3

Upgrade is dangerous

2010年8月18日星期三

Page 11: Upgrading to rails3

But !

2010年8月18日星期三

Page 12: Upgrading to rails3

台灣現在有在用 rails3 的,大概只有我跟 [*****]吧 XDXD

6/09 上午3:33:08 ihower

2010年8月18日星期三

Page 13: Upgrading to rails3

怒字Cost: 3h4m

2010年8月18日星期三

Page 14: Upgrading to rails3

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日星期三

Page 15: Upgrading to rails3

What will you face? (major)

• Query API change.

• HTML auto Escape

• Routing Changes

• Unobtrusive Javascript

• Plugin Broken ( internal API Channges )

2010年8月18日星期三

Page 16: Upgrading to rails3

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日星期三

Page 17: Upgrading to rails3

Rails Best Practices

• Move code from Controller to Model

• Extract into Module

• Never logic code in Views

• Organize Helper files

2010年8月18日星期三

Page 18: Upgrading to rails3

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日星期三

Page 19: Upgrading to rails3

Normally, you will fail...

2010年8月18日星期三

Page 20: Upgrading to rails3

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日星期三

Page 21: Upgrading to rails3

prepare well before starting

2010年8月18日星期三

Page 22: Upgrading to rails3

Resources

• The Rails 3 Upgrade Handbook

• Bundler

• RailsPlugins.org

• The Lowdown on Routes in Rails.

• Unobtrusive Javascript in Rails 3

2010年8月18日星期三