Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rails deprecation warning に立ち向かう技術 / v.s. rails...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
megane42
December 20, 2023
Programming
780
0
Share
Rails deprecation warning に立ち向かう技術 / v.s. rails deprecation warnings
megane42
December 20, 2023
More Decks by megane42
See All by megane42
Immutable ActiveRecord
megane42
0
330
OSS コミットゴルフのすすめ / Let's play OSS-contribute-golf
megane42
0
120
ゆる計算理論ラジオ / P vs NP for beginner
megane42
1
270
How to Make "DJ giftee"
megane42
1
980
Rails 6 Upgrade "Practical" Guide
megane42
6
1.4k
updated_at に依存したら大変なことになった / Don't depend on updated_at
megane42
0
630
本当は怖い Rails の `build_xxx` / The Hard Facts of `build_xxx` of Rails
megane42
0
280
Other Decks in Programming
See All in Programming
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.9k
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
400
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
2.9k
20年以上続くプロダクトでも使い続けられる静的解析ツールを求めて
matsuo_atsushi
0
140
The Less-Told Story of Socket Timeouts
coe401_
3
1.1k
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.6k
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
1k
[RubyKaigi 2026] Require Hooks
palkan
1
310
Back to the roots of date
jinroq
0
780
Terraform言語の静的解析 / static analysis of Terraform language
wata727
1
140
Firefoxにコントリビューションして得られた学び
ken7253
2
160
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
180
How to make the Groovebox
asonas
2
2.2k
Optimizing for Happiness
mojombo
378
71k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
240
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
180
How to Think Like a Performance Engineer
csswizardry
28
2.6k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
360
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
55k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.2k
Transcript
deprecation warning に ⽴ち向かう技術 2023/12/20 gotanda.rb #56 Hikaru Kazama (@megane42)
⾃⼰紹介 • ギフティのバックエンドエンジニア • 最近のコントリビュート:Kaigi on Rails アプリに⽬次を実装 • 実装⽇:最終⽇の翌⽇
課題 • Rails のバージョンアップに伴って、これまで使っていた機能 が deprecation (⾮推奨) になることがある • ぼんやりしているとログに吐かれた
deprecation warning を ⾒逃してしまい、後⽇実際に機能が削除 / 変更されてエラーが 起きてしまう
提案 • 実は deprecation warning が発⽣したときのふるまいを 変更できるので、変えてみましょう
config.active_support.deprecation • ⾮推奨機能を使ってしまったときのふるまいを定義できる • development / test 環境では :raise にしておくと便利
config.active_support.disallowed_deprecation • いきなり全体のふるまいを変えるのはちょっと… という⼈向け • 「この違反は潰した」というものだけを個別に設定すると、 その違反が再発したときだけ raise させたりできる
指定できるアクション • raise (エラーを発⽣) • stderr (標準エラーに出⼒) • log (ログに出⼒)
• notify (ActiveSupport::Notifications で通知) • silence (何もしない) https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/Behavior.html
指定できるアクション • raise (エラーを発⽣) • stderr (標準エラーに出⼒) • log (ログに出⼒)
• notify (ActiveSupport::Notifications で通知) • silence (何もしない) https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/Behavior.html
ActiveSupport::Notifications • 実は Rails の中にはいろんなイベントが⾶び交っている • イベントを subscribe することで、任意の処理を実⾏できる •
initializers などで購読すればよい
Slack 通知してみるなど • 購読するイベントは `deprecation.rails` • `payload[:message]` から警告メッセージが取得可能 • `payload[:callstack]`
からスタックトレースが取得可能
正論 • deprecation warning なんて、テストカバレッジが⼗分⾼けれ ば、1 回テスト流すだけで検知できるんじゃないの?
正論 • deprecation warning なんて、テストカバレッジが⼗分⾼けれ ば、1 回テスト流すだけで検知できるんじゃないの?
まとめ • deprecation warning が発⽣しても、 デフォルトの挙動は単にログに吐くだけ • 設定を変更するとエラーを raise させられる
• 開発環境でおすすめ • 設定を変更するとイベント通知させられる • 本番環境でおすすめ • そもそも Rails にイベント購読という概念があるのがおもしろい