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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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.9k
失敗から学ぶ個人開発
zaru_sakuraba
18
5.6k
伝わらない Issue の書き方
zaru_sakuraba
1
1.3k
Ruby との対話 : pry を使い pry をデバッグし pry のバグを直す話
zaru_sakuraba
4
650
もう「クレデンシャルください」なんて言わせない
zaru_sakuraba
5
1.7k
個人プロジェクト現状報告会
zaru_sakuraba
0
170
僕と契約して、メソッドになってよ!
zaru_sakuraba
0
230
Other Decks in Technology
See All in Technology
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
16
120k
覗いてみよう 関数型ビジュアル言語×2Dグラフィックスの世界
yohyamasaki
0
160
VS Code × GitHub Copilot での Fabric 開発
ryomaru0825
1
210
[2026 Oracle Technical Deep Dive] AI時代のデータベース基盤をどう選ぶ? Exadata Database Serviceの選択肢と使い分け (2026年9月17日開催)
oracle4engineer
PRO
0
150
IR Today: Theory, Practice, and Agents
dtunkelang
0
310
FinTech 1-2 : Overview of FinTech
ks91
PRO
0
120
Execution in the Kingdom of Agents: Reflections on Abstraction and Complexity
bcantrill
0
660
『GOエコノミー 』(相乗りサービス) におけるスペック駆動開発
mot_techtalk
1
160
Codex概要
ymiya55
0
180
The kernel report
ennael
PRO
1
190
Snowflake Horizon Catalog と Apache Iceberg で作る オープンなデータ基盤
kitagawaz
0
370
Lambda MicroVMsは常駐サーバーの代わりに なるか? Kiro Crew を動かして検証してみた / Kiro Crew on Lambda MicroVMs
k_adachi_01
2
350
Featured
See All Featured
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Building AI with AI
inesmontani
PRO
1
1.3k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
300
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Design in an AI World
tapps
1
340
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
WENDY [Excerpt]
tessaabrams
14
40k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
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
どんどん良くしていくぞ! という気持ち