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
New Features in Rails 4.2
Search
murajun1978
February 21, 2015
Programming
960
0
Share
New Features in Rails 4.2
murajun1978
February 21, 2015
More Decks by murajun1978
See All by murajun1978
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
1.2k
How to Enjoy the Murajun’s Style
murajun1978
0
96
Building Tebukuro with Hotwire and Rails
murajun1978
0
1.5k
Zeitwerk integration in Rails 6.0
murajun1978
0
130
Efficient development with GraphQL
murajun1978
0
330
Effective Debugging Apps in VS Code
murajun1978
1
970
tebukuro
murajun1978
0
140
Shinosaka.rb #17 Hands on
murajun1978
0
70
shinosakarb #11 Rails 4 Pattenrs
murajun1978
1
180
Other Decks in Programming
See All in Programming
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.9k
Swift Concurrency Type System
inamiy
0
480
Vibe하게 만드는 Flutter GenUI App With ADK , 박제창, BWAI Incheon 2026
itsmedreamwalker
0
550
PDI: Como Alavancar Sua Carreira e Seu Negócio
marcelgsantos
0
120
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
390
「速くなった気がする」をデータで疑う
senleaf24
0
170
3分でわかるatama plusのQA/about atama plus QA
atamaplus
0
150
AWS re:Invent 2025の少し振り返り + DevOps AgentとBacklogを連携させてみた
satoshi256kbyte
3
160
存在論的プログラミング: 時間と存在を記述する
koriym
5
860
ファインチューニングせずメインコンペを解く方法
pokutuna
0
300
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
6.3k
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
150
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
880
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
The untapped power of vector embeddings
frankvandijk
2
1.7k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
290
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
470
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
670
Building an army of robots
kneath
306
46k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
120
Faster Mobile Websites
deanohume
310
31k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
350
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Transcript
New Features in Rails 4.2 ୈ65ճ Rubyؔ ษڧձ
about me ΉΒ͡ΎΜ murajun1978 Ruby <3 <3 <3
Shinosaka.rb #13 http://shinosakarb.doorkeeper.jp/events/19518 2 / 28
͢͜ͱ • Active Job • Global ID • Adequate Record
• Web Console • Foreign key support • Default Host for rails server
Active Job
Active Jobͱʁ queueing backends Active Job API Job adapter
Job࡞ $ rails generate job job_name
ಛఆͷΩϡʔͷJob࡞ $ rails generate job job_name —queue queue_name
JobΛΩϡʔʹొ
JobͷεέδϡʔϦϯά
ΞμϓλΛมߋ
ར༻Ͱ͖ΔΞμϓλ http://api.rubyonrails.org/classes/ActiveJob/ QueueAdapters.html
ίʔϧόοΫ • before_enqueue • around_enqueue • after_enqueue • before_perform •
around_perform • after_perform
Ωϡʔʹొ͞ΕΔ࣌ʹ࣮ߦ • before_enqueue • around_enqueue • after_enqueue
Job͕࣮ߦ͞ΕΔ࣌ʹ࣮ߦ • before_perform • around_perform • after_perform
ྫ֎ॲཧ
ඇಉظͰϝʔϧૹ৴
Global ID
URIʹΑΔϞσϧࢀর https://github.com/rails/globalid
Global IDͷੜ pry(main)> gid = post.to_gid => #<GlobalID:0x007f8ddfdb79e0 @uri=#<URI::GID gid://blog/Post/1>>
URI͕ੜ͞Εͨ ActiveRecordΦϒδΣΫτ
Global ID͔Β ModelͷใΛऔಘͯ͠ΈΔ gid.app #=> "blog" ɾΞϓϦέʔγϣϯ໊ ɾϞσϧ໊ gid.model_name #=>
"Post" ɾϞσϧΫϥε gid.model_class #=> Post(id: integer, title: string, published_at: datetime …) ɾID gid.model_id #=> "1"
Global ID͔ΒΦϒδΣΫτऔಘ globalid/lib/global_id/locator.rb GlobalID::Locator.locate gid => #<Post id: 1, title:
"Rubyؔ" ...>
Adequate Record
http://tenderlovemaking.com/2014/02/19/adequaterecord-pro- like-activerecord.html
ActiveRecord 2x faster ƅшƅ)ʂ
Rails 4.1 SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1
LIMIT 1 SELECT "posts".* FROM "posts" WHERE "posts"."id" = 2 LIMIT 1 ݅ͷ͕มΘ͚ͬͨͩͳͷʹɺΫΤϦΩϟογϡ͞Εͯͳ͍
Rails 4.2 SELECT "posts".* FROM "posts" WHERE "posts"."id" = ?
LIMIT 1 [["id", 1]] SELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT 1 [["id", 2]] Ωϟογϡ͞ΕͨΫΤϦʹΛ͍ͯ͠Δ
αϙʔτ͞Ε͍ͯΔͷ • find(id) • find_by(name: name) • find_by_name(name)
Ωϟογϡ͕ద༻͞Εͳ͍߹ • ϞσϧʹσϑΥϧτείʔϓ͕ઃఆ͞Ε͍ͯΔ • ϞσϧͰ୯Ұςʔϒϧܧঝ (STI) ͕༻͞Ε͍ͯΔ • PolymorphicΛͬͯΔ •
findͰ idͷྻΛ͢߹ • find(1,2) or find([1,2])
Web Console
ΤϥʔϖʔδͰσόοά
ಛఆͷϖʔδͰσόοά
ࢦఆIP͔ΒͷΈར༻͢Δ
Foreign Key Support
ϚΠάϨʔγϣϯͰ֎෦Ωʔ ͷՃɺআΛαϙʔτ
αϙʔτ͞ΕΔΞμϓλ • mysql • mysql2 • postgresql
Default Host for rails server
σϑΥϧτͷϗετ͕0.0.0.0͔Β localhost(127.0.0.1)ʹมߋ ֎෦PC͔ΒΞΫηε͢Δ߹ rails server -b 0.0.0.0
·ͱΊ • Active JobόοΫΤϯυͷΩϡʔγεςϜʹ͔͔ΘΒ ͣɺಉ͡هड़Ͱॻ͚Δ͕ྑ͍ • ܁Γฦ͢όονॲཧͳͲɺsidetipsidekiq-schedulerΛ ͏ͱྑ͍͔ • Global
IDActive JobҎ֎Ͱ͑ͦ͏ • Ruby on Rails 4.2 ϦϦʔεϊʔτಡ͏ • RailsͷContributorsʹײँ :)
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠