SlideShare a Scribd company logo
HOW TO UPGRADE ROR
FROM RAILS 3 TO RAILS 4
Wei-Yi, Chiu - 2016/11/18
OUTLINE
• introduction
• tutorial
• Incompatibilities
• gem upgradation
INTRODUCTION
HIGHLIGHT IN RAILS 4.0
• Ruby 2.0 preferred; 1.9.3 required
• Strong Parameters
• Turbolinks
• Russian Doll Caching
STRONG PARAMETERS
• 為了了解決mass-
assignment的安全性問
題
• attr_accessible /
attr_protected 並不適
⽤用
• 把MVC分清楚
TURNOLINKS
• Turbolinks for Rails
(like pjax)
• pjax: 只載入需要載入
的東⻄西
• turbolinks: 只重新載入
<body></body>
• data-no-turbolink
RUSSIAN DOLL CACHING
• view打cache的難題
• ⽤用updated_at當key 

=> 使⽤用touch
HIGHLIGHT IN RAILS 4.1
• Spring application preloader
• config/secets.yml
• Action Pack variants
• Action Mailer previews
• Active Record enums
SPRING / SECRETS.YML
• Spring
• 縮短開發時間
• 在背景執⾏行行⼀一個rails app,執⾏行行rake的時候,rails
就不⽤用再重啟了了
• config/secret.yml
• 把所有的secret統⼀一管理理
ACTION PACK VARIANTS
ACTION MAILER PREVIEWS
ACTION MAILER PREVIEWS
HIGHLIGHT IN RAILS 4.2
• Adequate Record:速度更更快(2x)的find_by
• Web Console:⼤大家都看到了了
• Active Job
• Asynchronous mails
• Foreign key support
ACTIVE JOB
• queuing system的統⼀一
接⼝口
ACTION MAILER
• deliver! 已經無法使⽤用
• deliver_now /
deliver_later
FOREIGN KEY SUPPORT
FOREIGN KEY SUPPORT
TUTORIAL
TUTORIAL
• rvm install ruby-2.2.1
• localhost: 2.2.1
• server: 2.1.9
• rails app:update
• use rails:update on 4.2 and earlier
• bundle update
「然後開始按照rails 4的doc改code...」
INCOMPATIBILITIES
INCOMPATIBILITIES IN RAILS
4.0
• Strong parameters
• default using dalli in
ActiveSupport::Cache::MemCacheStore.
• Model.all now returns an ActiveRecord::Relation
INCOMPATIBILITIES IN RAILS
4.0
INCOMPATIBILITIES IN RAILS
4.1
• String#remove(pattern) as String#gsub(pattern,’')
• Added Time.zone.yesterday and
Time.zone.tomorrow.
INCOMPATIBILITIES IN RAILS
4.2
• render “foo/bar" => render template: ”foo/bar”
• respond_with and the corresponding class-level
respond_to have been moved to the responders
gem.
• Default Host for rails server
• The *_filter family of methods have been removed
from the documentation. Their usage is discouraged
in favor of the *_action family of methods:
GEM UPGRADATION
UNINTIALIZED CONTENT
ARE:SQLITERAL
• 發⽣生時機:當cache_store使⽤用dalli,且dalli上已經
有rails 4以前的cache時
• 原因:rails4/dalli相依的arel改版後沒有Sqliteral了了
• 解決⽅方式:
• 等到錯誤的cache過期
• 開⼀一個新的memcache
GOOGLE DOC 無法寫入資料
• 發⽣生時機:要連進google doc建立session時
• 原因:rails4相依的google-api-client改版後沒有
Google::APIClient::JWTAsserter了了
• 解決⽅方式:
• 程式改寫
GOOGLE DOC 無法寫入資料
改變了了RENDER JSON的預設格式
Rails 3 Rails 4
END

More Related Content

PDF
8 彭立勳-double binlog方案
PDF
用Maven管理專案的依賴關係
PDF
美团点评技术沙龙06 - 滴滴移动端测试解耦工具实践
PDF
The Rails 4 Way Chapter 1
PDF
Serverless Event Streaming with Pulsar Functions-xiaolong
PPTX
LaravelConf Taiwan 2017 單頁面應用與前後端分離開發
PDF
Improvements Made in KoP 2.9.0 - Pulsar Summit Asia 2021
PPTX
Kafka cluster best practices
8 彭立勳-double binlog方案
用Maven管理專案的依賴關係
美团点评技术沙龙06 - 滴滴移动端测试解耦工具实践
The Rails 4 Way Chapter 1
Serverless Event Streaming with Pulsar Functions-xiaolong
LaravelConf Taiwan 2017 單頁面應用與前後端分離開發
Improvements Made in KoP 2.9.0 - Pulsar Summit Asia 2021
Kafka cluster best practices

What's hot (20)

PPTX
Asp.net mvc 6 新功能初探
PDF
WireMock 起飞手册
PDF
Route路由控制
PDF
開發環境建置
PDF
COSCUP 2016 Laravel 部署工作坊 - 部署指南
PPTX
The Evolution History of RoP(RocketMQ-on-Pulsar) - Pulsar Summit Asia 2021
PDF
Mock Server的应用与实践
PPTX
Asp.net 5 新功能與變革
PPT
Boohee ruby on rails practise
PPTX
Entity framework + Linq 介紹
PDF
Nodejs & NAE
PDF
Java类加载器
PPTX
Opening Remarks - Pulsar Summit Asia 2021
PDF
Vagrant教學
PPT
20110607 IPv6
PDF
開發環境建置
PDF
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu
PPT
The Application of OpenStack in 360buy, by Bin He
PPTX
OPC Basic Introduction in Chinese
PDF
應用程式佈署
Asp.net mvc 6 新功能初探
WireMock 起飞手册
Route路由控制
開發環境建置
COSCUP 2016 Laravel 部署工作坊 - 部署指南
The Evolution History of RoP(RocketMQ-on-Pulsar) - Pulsar Summit Asia 2021
Mock Server的应用与实践
Asp.net 5 新功能與變革
Boohee ruby on rails practise
Entity framework + Linq 介紹
Nodejs & NAE
Java类加载器
Opening Remarks - Pulsar Summit Asia 2021
Vagrant教學
20110607 IPv6
開發環境建置
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu
The Application of OpenStack in 360buy, by Bin He
OPC Basic Introduction in Chinese
應用程式佈署
Ad

How to upgrade_ror3_to_ror4