Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rails 6: ActiveRecord
Search
Nikolay Sverchkov
November 30, 2019
Programming
46
0
Share
Rails 6: ActiveRecord
Nikolay Sverchkov
November 30, 2019
More Decks by Nikolay Sverchkov
See All by Nikolay Sverchkov
Authorization in the GraphQL era
ssnickolay
0
970
Serverless Is Ruby Future
ssnickolay
0
820
Anything new Rails 6?
ssnickolay
1
1.4k
Serverless for mere mortals
ssnickolay
1
940
Evolution of Rails application architecture: 14 years in production
ssnickolay
3
1.3k
A Healthy Monolith
ssnickolay
0
1.4k
Elixir. There and Back Again
ssnickolay
0
770
Other Decks in Programming
See All in Programming
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
480
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
230
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
280
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
200
ドメインイベントでビジネスロジックを解きほぐす #phpcon_odawara
kajitack
3
790
煩雑なSkills管理をSoC(関心の分離)により解決する――関心を分離し、プロンプトを部品として育てるためのOSSを作った話 / Solving Complex Skills Management Through SoC (Separation of Concerns)
nrslib
4
980
事業会社でのセキュリティ長期インターンについて
masachikaura
0
260
Back to the roots of date
jinroq
0
280
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
790
ハンズオンで学ぶクラウドネイティブ
tatsukiminami
0
130
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
3
560
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
620
Featured
See All Featured
A Soul's Torment
seathinner
6
2.7k
The Curse of the Amulet
leimatthew05
1
11k
Visualization
eitanlees
150
17k
Embracing the Ebb and Flow
colly
88
5k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
310
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.6k
The World Runs on Bad Software
bkeepers
PRO
72
12k
GitHub's CSS Performance
jonrohan
1032
470k
BBQ
matthewcrist
89
10k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
380
The Pragmatic Product Professional
lauravandoore
37
7.2k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Transcript
NIKOLAY SVERCHKOV @ssnickolay ACTIVE RECORD 6+
#saintprubyconf @ssnickolay
@ssnickolay RAILS 6.0 MULTIPLE DATABASE SUPPORT
@ssnickolay gem ‘octopus’
@ssnickolay gem ‘octopus’ FOCUSED ON
@ssnickolay RAILS 6.0: MULTI DB MULTI DB = DB SHARDING
= + + + VERTICAL OR HORIZONTAL PARTITIONING / REPLICATION
@ssnickolay RAILS 6.0: MULTI DB RAILS DID NOT HAVE ADEQUATE*
MULTI DB SUPPORT *https://github.com/ankane/multiverse
@ssnickolay RAILS 6.0: MULTI DB MULTI DB !!= DATABASE SHARDING
@ssnickolay AT LEAST 12 HUGE PRS FROM @EILEENCODES RAILS 6.0:
MULTI DB
WHEN YOU RELEASE THE NEW FEATURE
@ssnickolay RAILS 6.0: MULTI DB MULTI DB !!= DATABASE SHARDING
?
@ssnickolay RAILS 6.0: MULTI DB MULTI DB !!= DATABASE SHARDING
@ssnickolay RAILS 6.0: BULK INSERTS # Insert multiple records, performing
an upsert # when records have duplicate ISBNs Book.upsert_all([ { title: 'Rework', author: 'David', isbn: '1' }, { title: 'Eloquent Ruby', author: 'Russ', isbn: '1' } ], unique_by: { columns: %w[ isbn ] }) *gem ‘activerecord-import`
@ssnickolay RAILS 6.0: update Rails 4.0.2 update_attributes(column: value) update(column: value)
Rails 6+ update(column: value) Deprecate `update_attributes`
@ssnickolay RAILS 6.0: update Rails 4.0.2 update_attributes(column: value) update(column: value)
Rails 6+ update(column: value) Deprecate `update_attributes`
@ssnickolay RAILS 6.0: create_or_find_by find_or_create_by vs create_or_find_by
@ssnickolay find_or_create_by def find_or_create_by!(attributes, &block) find_by(attributes) !|| create!(attributes, &block) end
@ssnickolay find_or_create_by def find_or_create_by!(attributes, &block) find_by(attributes) !|| <Вот-Тут-> create!(attributes, &block)
end
@ssnickolay RAILS 6.0: create_or_find_by def create_or_find_by(attributes, &block) transaction(requires_new: true) {
create(attributes, &block) } rescue ActiveRecord!::RecordNotUnique find_by!(attributes) end
@ssnickolay RAILS 6.0: create_or_find_by def create_or_find_by(attributes, &block) transaction(requires_new: true) {
create(attributes, &block) } rescue ActiveRecord!::RecordNotUnique <Вот-Тут-> find_by!(attributes) end
@ssnickolay RAILS 6.0: Other • Make t.timestamps with precision by
default • Add support for UNLOGGED Postgresql tables • Add support for annotating queries generated by ActiveRecord::Relation with SQL comments • Make it possible to override the implicit order column • …