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
はじめてのPLATEAU
nokonoko1203
1
570
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
230
SODA - FACT BOOK(EN)
sodainc
1
210
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
120
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
410
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
150
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
130
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
330
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
330
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
4
1.5k
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
5.1k
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
16
8.7k
Featured
See All Featured
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
660
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
510
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
3k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Unsuck your backbone
ammeep
672
58k
Bash Introduction
62gerente
615
220k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Crafting Experiences
bethany
1
430
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Utilizing Notion as your number one productivity tool
mfonobong
4
640
Mind Mapping
helmedeiros
1
430
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)