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
0
890
New Features in Rails 4.2
murajun1978
February 21, 2015
Tweet
Share
More Decks by murajun1978
See All by murajun1978
Building Tebukuro with Hotwire and Rails
murajun1978
0
1.1k
Zeitwerk integration in Rails 6.0
murajun1978
0
100
Efficient development with GraphQL
murajun1978
0
280
Effective Debugging Apps in VS Code
murajun1978
1
860
tebukuro
murajun1978
0
110
Shinosaka.rb #17 Hands on
murajun1978
0
43
shinosakarb #11 Rails 4 Pattenrs
murajun1978
1
110
FactoryGirl LT
murajun1978
1
66
Shinosaka.rb #3
murajun1978
0
51
Other Decks in Programming
See All in Programming
JaSST 24 九州:ワークショップ(は除く)実践!マインドマップを活用したソフトウェアテスト+活用事例
satohiroyuki
0
320
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.1k
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
120
Jakarta EE meets AI
ivargrimstad
0
120
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
160
JavaでLチカしたい! / JJUG CCC 2024 Fall LT
nhayato
0
110
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
290
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
230
ヤプリ新卒SREの オンボーディング
masaki12
0
110
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
440
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
400
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.2k
Featured
See All Featured
RailsConf 2023
tenderlove
29
890
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Become a Pro
speakerdeck
PRO
25
5k
We Have a Design System, Now What?
morganepeng
50
7.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
360
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
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ʹײँ :)
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠