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
とあるプロジェクトでコードを書き始めた僕がつまづいた石たち
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
zaru
April 05, 2019
Technology
220
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
とあるプロジェクトでコードを書き始めた僕がつまづいた石たち
zaru
April 05, 2019
More Decks by zaru
See All by zaru
Next.js App Router セキュリティ
zaru_sakuraba
22
8.8k
Hotwire を 本番環境で使ってみた感想
zaru_sakuraba
7
6.8k
失敗から学ぶ個人開発
zaru_sakuraba
18
5.6k
伝わらない Issue の書き方
zaru_sakuraba
1
1.3k
Ruby との対話 : pry を使い pry をデバッグし pry のバグを直す話
zaru_sakuraba
4
640
もう「クレデンシャルください」なんて言わせない
zaru_sakuraba
5
1.7k
個人プロジェクト現状報告会
zaru_sakuraba
0
160
僕と契約して、メソッドになってよ!
zaru_sakuraba
0
220
Other Decks in Technology
See All in Technology
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
450
Screen Lens - 今見てる画面を翻訳する
komagata
0
240
幾何アルゴリズムで なめらかなピン操作を / iOSDC Japan 2026 / smoothpin
kazumanagano
0
250
Sigmaユーザーのための有用リソース一挙公開 & Sigmaで使えるMCP #sigma_ucj /useful-resources-for-sigma-computing-users-and-mcps-with-sigma
shinyaa31
0
180
Multica × 長期記憶:40個のミニプロジェクト管理
eiei114
1
240
AIネイティブプロダクトで顧客価値を最大化するプロダクトエンジニアとFDEの協働
righttouch
PRO
0
230
DEFCON_CHV_CTF_Write-up.pdf
bata_24
0
130
あるけみー式LTスライド作成術
alchemy1115
1
170
Microsoft 365 Copilot chat -tekoälypalvelun tietosuojaongelmat
hponka
0
650
薬剤師(ドメインエキスパート)と一緒に育てる薬局向けAIアシスタント
kakehashi
PRO
2
140
From Vanilla Kubernetes to a Batteries-Included Platform: Developer Experience at 1,300+ Clusters
yosshi_
0
680
enechainの内製セルフサービスプラットフォーム
hiyosi
0
150
Featured
See All Featured
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Mind Mapping
helmedeiros
1
350
Agile that works and the tools we love
rasmusluckow
331
22k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
The agentic SEO stack - context over prompts
schlessera
0
920
Amusing Abliteration
ianozsvald
1
290
Being A Developer After 40
akosma
91
590k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Scaling GitHub
holman
464
140k
Google's AI Overviews - The New Search
badams
0
1.6k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Transcript
とあるプロジェクトで コードを書き始めた僕が つまづいた石たち 2019.04.05 TGIF @zaru
site = Site.find site_id
いたるところにある Site.find id | Site.find name … site.name というのは c1234567890
のような識別子
まさかの find を override していた def find id any_of({_id: id},
{name: id}).first end id もしくは name どちらでもヒットする 気持ちはわかるけど検索キーはどちらかに統一したほうが良い なぜならアプリケーション全体で id と name どちらで持ち回るのか が曖昧になる。ここで透過的に処理するのではなく、もう少し手前 で透過的な処理をしたほうが良い 例外出すと信じてたのに…
site = Site.find site_id
特定ドキュメントの場合、とにかく遅い 大量にある embeds_many が原因 ferret One サービスサイトだと 5MB 以上ある fetch
するのに 200-300msec くらいかかってた Site.without(:hoge) や Site.only(:piyo) でスリムに 20-30msec くらいに改善 embeds_many -> has_many にしたい
Site.without(:hoge).find
mongoid の仕様で一部のフィールドのみを取得した場合は save でき ない set で直接書き換えるしかない… site = Site.without(:hoge).first
site.title = 'update' site.save # NG site.set(title: 'update') # OK これは今後しんどくなりそうな雰囲気を感じている ActiveRecord ってどうだったっけ… ?
response = RestClient.get(query_images)
これ自体はなんてことはない普通のコード rest-client という gem を使っている ただし Gem le には rest-client
は存在しない mailjet というメール配信の gem が rest-client に依存 それを利用している… しかし mailjet はもう使っていないので gem を削除すると死ぬ そして faraday という別の HTTP クライアント gem がありバッティ ングしている
resources :hoge
resources :hoge ← 全部 action あるのかな? 実は使っているのは update だけでした only
except を使った方が良い
# TODO: これは使われているのか… ?
テストコードやリファクタをする際に、メソッドが使われているの か使われていないのかが、すぐ判断できなかった そのメソッドに依存したコードが山のようにあるし URL も露出し ている lograge -> redash があったので実際に
call されているかどうかで判 断 使わなくなったコードはすぐに削除しましょう
TemporaryPage.find(1).site_id
Site has_many Page TemporaryPage extends Page temporary_page.site #=> <Site ....>
temporary_page.site_id #=> nil リレーションしているのだからあるはずでは… ? def site で定義されていた… def site self.public_page.try(:site) end
どんどん良くしていくぞ! という気持ち