Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Enumのvalidateオプションで しくじった話
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
nakayama-bird
November 27, 2025
Programming
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Enumのvalidateオプションで しくじった話
2025.11.27 Ruby on Railsのテーブル設計とトランザクション処理 LT Night
nakayama-bird
November 27, 2025
More Decks by nakayama-bird
See All by nakayama-bird
非同期×イベント分離でMtgを短縮!
nakayama__bird
1
440
はじめてのRailsの ソースコードリーディング
nakayama__bird
1
89
Other Decks in Programming
See All in Programming
一人だけ、Kiroが静止する日
hideg
0
110
AIエージェント時代のコードレビューを設計する
nogu66
6
2.7k
アクセシビリティから考える情報設計
high_g_engineer
0
380
A2UI for Android: Safely Rendering AI-Generated UI with Jetpack Compose - DroidKaigi 2026
itsmedreamwalker
0
140
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
110
AHC070解法紹介
eijirou
0
120
iOSDC2026登壇資料.pdf
riofujimon
0
160
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.9k
FreeBSDでZabbixを動かす.pdf
kenkino
0
280
How I Stole PSI from Android Studio - DroidKaigi2026
worker8
0
130
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
410
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
160
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
380
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
The Curious Case for Waylosing
cassininazir
1
510
Designing Experiences People Love
moore
143
24k
Crafting Experiences
bethany
1
340
Docker and Python
trallard
47
4.2k
A Soul's Torment
seathinner
8
3.6k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
300
Embracing the Ebb and Flow
colly
88
5.2k
Building AI with AI
inesmontani
PRO
1
1.2k
Transcript
© Findy Inc. 2025.11.27 Ruby on Railsのテーブル設計とトランザクション処理 LT Night Enumのvalidateオプションで
しくじった話 1 ファインディ株式会社 Team+開発部 中嶋 ひかる
© Findy Inc. 2 ⾃⼰紹介 中嶋 ひかる @nakayama__bird 経歴 前職:公務員(税関職員🛃)
オンラインのプログラミングスクールを経て、 2024/12にファインディに⼊社 RailsメインでFindy Team+の開発してます RubyとRails歴は2年くらいです
© Findy Inc. Railsのenumって便利ですよね 3
© Findy Inc. 4 こんな感じで定義をすれば Userの権限をenumで定義する(⼀部抜粋)
© Findy Inc. 5 Rubyっぽいメソッドで問い合わせできる Predicate Methods(述語メソッド)= 末尾に疑問符?がつき、真偽値(boolean値)を返すメソッド
© Findy Inc. 6 scopeで絞り込みできる 実質的に User.where(role: :admin) と同じ絞り込みが直感的に書ける
© Findy Inc. enumのvalidate: trueについて 7
© Findy Inc. 8 enumのvalidateオプションについて ‧Rails 7.1で追加された https://railsguides.jp/7_1_release_notes.html ‧enumに、validate: trueのオプションを設定すると、enumにある値以外を受け取った場合に、バリデー
ションのエラーとなるようになった https://github.com/rails/rails/pull/49100 ‧デフォルトはfalseで、その場合はArgument Errorが発⽣する
© Findy Inc. enumのvalidateオプションで しくじった話 9
© Findy Inc. 10 外部APIからのレスポンスで列挙型のプロパティがあった ‧ドキュメントで列挙されている内容をenumで定義 ‧validate: trueで設定した propertyには下記のようなも のがあります
‧status ‧title ‧label …
© Findy Inc. 11 実際に取得処理をしたら別のプロパティがあった ‧バリデーションエラーが発⽣ ‧ドキュメントには掲載されていないpropertyが複数あった ‧エラーになったプロパティを確認しenumに追加した ‧今後も新たなプロパティの追加があると考えvalidate: trueのオプションを外した
© Findy Inc. 12 時は流れてリリース後 ‧Argument Errorエラーになっている!! ‧新しくemailというpropertyが追加された+validate: trueのオプションを外したことでぱっと⾒でなんのエ ラーかわからない状況になってしまった
‧⼀時対応としてpropertyのenumにemailを追加することで対応
© Findy Inc. 13 反省点、今後の⽅針、まとめ ‧validate: trueの挙動を正しく理解せず変更を⾏ってしまった=>いずれにせよエラーにはなるがバリデー ションエラーの⽅が原因把握しやすかった ‧そもそもenumではなくしてしまうという⽅針もあったが、プロダクトとしてそのTypeに対応するしない の判断を⾏うために列挙型は維持したい
‧取得時、enumに定義されていないものがあった場合にはunknownで⼀旦インポート処理してデータを確 認=>enumに追加が流れとして良さそう?という話になっている ‧外部APIの列挙型のデータの扱い⽅について気になるのでお話し聞きたいです!
© Findy Inc. ご清聴いただきありがとうございました! 14