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
0
33
Rails 6: ActiveRecord
Nikolay Sverchkov
November 30, 2019
Tweet
Share
More Decks by Nikolay Sverchkov
See All by Nikolay Sverchkov
Authorization in the GraphQL era
ssnickolay
0
680
Serverless Is Ruby Future
ssnickolay
0
630
Anything new Rails 6?
ssnickolay
1
1.2k
Serverless for mere mortals
ssnickolay
1
730
Evolution of Rails application architecture: 14 years in production
ssnickolay
3
1.1k
A Healthy Monolith
ssnickolay
0
1.1k
Elixir. There and Back Again
ssnickolay
0
570
Other Decks in Programming
See All in Programming
技術好きなエンジニアが "リーダーへの進化" によって得たものと失ったもの
pospome
5
1.3k
SwiftUIのObservationツールの挙動をテストしてみた
kenshih522
0
110
ベクトル検索システムの気持ち
monochromegane
9
2.8k
もう一人で悩まない! 個の知見をチームの知見にする3つの習慣と工夫 / Into team knowledge.
honyanya
3
500
「その気にさせる」エンジニアが 最強のリーダーになる理由
gimupop
3
450
SLI/SLOの設定を進めるその前に アラート品質の改善に取り組んだ話
tanden
2
430
バックエンドNode.js × フロントエンドDeno で開発して得られた知見
ayame113
4
1.2k
remix + cloudflare workers (DO) docker上でいい感じに開発する
yoshidatomoaki
0
100
아직도 SOLID 를 '글'로만 알고 계신가요?
sh1mj1
0
340
JavaOne 2025: Advancing Java Profiling
jbachorik
1
290
DenoでOpenTelemetryに入門する
yotahada3
2
270
PHPer's Guide to Daemon Crafting Taming and Summoning
uzulla
2
560
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
12
1.4k
Writing Fast Ruby
sferik
628
61k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
The Language of Interfaces
destraynor
156
24k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
22
2.6k
Facilitating Awesome Meetings
lara
53
6.3k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
For a Future-Friendly Web
brad_frost
176
9.6k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.4k
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 • …