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
User.create(admin: 'False').admin
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
nissyi
March 08, 2023
Programming
2
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
User.create(admin: 'False').admin
2023/03/08 Shibuya.rb
nissyi
March 08, 2023
More Decks by nissyi
See All by nissyi
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.6k
Kaigi_on_Rails_2022スポンサーLT登壇資料.pdf
yuta_onishi_97
1
1.3k
Other Decks in Programming
See All in Programming
AI-Powered Domain-Driven Design
ziobrando
0
400
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
150
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
110
Modernizing iOS Apps
seyfoyun
0
150
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
170
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
330
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
3
1.4k
SODA - FACT BOOK(JP)
sodainc
1
40k
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
160
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
3
1.7k
TanStack Vue Query と Pinia Colada から学ぶ非同期状態の型設計
aoshi
0
620
Performance Optimization With LLMs
xleitix
0
240
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
950
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Designing Experiences People Love
moore
143
24k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1.1k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
320
It's Worth the Effort
3n
188
29k
エンジニアに許された特別な時間の終わり
watany
109
250k
How to Talk to Developers About Accessibility
jct
2
610
Fireside Chat
paigeccino
43
4.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
How STYLIGHT went responsive
nonsquared
100
6.4k
Transcript
User.create(admin: ʻFalseʼ).admin 2023/03/08 nissyi(大西 裕太)in Shibuya.rb
説明用のUserモデル • 管理者どうかを判定するBoolean値を持つadminカラムを持ちます。 • Modelもいじってません。 •
タイトルの返り値は?
User.create(admin: ʻFalseʼ).admin
User.create(admin: ʻFalseʼ).admin => true
None
None
ActiveModel::Type::Boolean
None
FALSE̲VALUESに含まれていたらfalse ということで実験
FALSE̲VALUESに含まれていたらfalse ということで実験
FALSE̲VALUESに含まれていたらfalse ということで実験
似たような値なら?
FALSE̲VALUESに含まれていたらfalse
FALSE̲VALUESに含まれていたらfalse
nilか空文字列の場合は?
nilか空文字列なら? nilの場合はnilです。
nilか空文字列なら? 空文字列の場合もnilです。
コメントに書かれてた
コメントに書かれてた
ActiveModel::Type::Value#cast
ActiveModel::Type::Value#cast
ActiveModel::Type::Boolean
ActiveModel::Type::Boolean
最後に • 挙動調べてみて面白かった • downcaseとかでまとめられるのでは?🤔 => issueとかPRまで読んでみたら実装の意図を理解できるかも • “OFF” でもfalseにできるの!?
Twitterやってます(@yuta̲onishi̲97)