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
ぼくが考える最強のApplicationModel @表参道.rb #43
Search
YABOO JAPAN
February 07, 2019
0
620
ぼくが考える最強のApplicationModel @表参道.rb #43
YABOO JAPAN
February 07, 2019
Tweet
Share
More Decks by YABOO JAPAN
See All by YABOO JAPAN
RubyKaigiでもらった熱量がOSSに変換された話@AFTER RubyKaigi 2019
yaboojp
0
2.3k
RailsでViewModel導入に 挫折しかけてる話@表参道.rb #44
yaboojp
1
710
サービス開発する平成の君に 昭和の僕から伝えたい7つのこと@平成.rb #2
yaboojp
0
680
RailsのCacheつかってますか?@表参道.rb #44
yaboojp
0
670
夏休みの宿題 8/31にやらない話 @Otemachi.rb #14
yaboojp
0
290
大掃除 on Rails @Otemachi.rb #12
yaboojp
1
29
使わない機能の倒し方 @s-dev talks 〜サービス開発勉強会〜 大忘年LT大会
yaboojp
0
70
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
288
19k
How to Ace a Technical Interview
jacobian
272
22k
The Brand Is Dead. Long Live the Brand.
mthomps
48
27k
Bash Introduction
62gerente
604
210k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
1
3.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
355
22k
Optimizing for Happiness
mojombo
369
69k
Infographics Made Easy
chrislema
237
18k
Writing Fast Ruby
sferik
619
60k
Web Components: a chance to create the future
zenorocha
304
41k
KATA
mclloyd
14
12k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
225
51k
Transcript
΅͕͘ߟ͑Δ࠷ڧͷ ApplicationModel @yaboojp on Omotesando.rb #43 2019/2/6
Self • Name: େ༅ Ӭ / @yaboojp • Jobs: •
22Inc. Co-Founder & CTO @தࠇ • ex NTTdata @ஙʙ๛ऱ • Location: ژ -> ౦ژ • Favorites: Ϗʔϧ, Իָ, όΠΫ, JALϚΠϧ
None
ActiveRecord͡Όͳ͍ ModelઃܭͲ͏ͯ͠·͔͢ʁ
ฐࣾ • جຊతʹɺActiveModelύλʔϯ • PORO(Plain Old Ruby Object)ͰStructΛར༻ ͢Δͷྑͦ͞͏ͱࢥ͍ͭͭ •
ActiveModel::Attributes͕Rails5.2͔Β͑Δ ͷͰͬͺΓActiveModel͕ྑͦ͞͏
ActiveModel::Attributes
ॳ LT͠Α͏ͱͯͨ͠ωλ • not Rails 5.2
ActiveModel::DirtyͰมߋݕ
ɹʊਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹɹɹɹɹɹɹɹɹɹɹɹʻ ʼɹ ͢ωλ͕ͳ͘ͳͬͨ ɹʻ ʼɹɹɹɹɹɹɹɹɹɹɹɹʻ ɹʉY^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ʉ
ॳ LT͠Α͏ͱͯͨ͠ωλ • Rails 5.2Ҏ߱ͰෆཁͳϋοΫ
݁
Thanks
Thanks
None
None
Ͳ͏ͯ͜͠͏ͳͬͨʁ
ແବ ແବ ແବ ແବ
ActiveModelͷؾ࣋ͪʹͳΔ
None
૯ͨΓͷମͨΓ
Model
Attributes
Dirty
Serializers::JSON • API࣮ͰΑ͘ΘΕͯΔ • ::XMLͱ͔ଞͷϑΥʔϚοτͳ͔ͬͨ • ActiveModel::SerializationΛؚΉ
Validations • ActiveModel::Modelʹؚ·ΕΔ
Validator • ActiveModel::Modelʹؚ·ΕΔ
Attribute_methods • ActiveModel::Attributesʹinclude͞ΕͯΔ • prefix/suffix͖ͷڞ௨ϝιουΛ֤attribute ʹఆٛͰ͖Δ • ෦࣮ɺmethod_missingࠇຐज़
Attribute_mutation_tracker • ActiveModel::DirtyͰΘΕ͍ͯΔΤϯςΟ ςΟΫϥε
Attribute_set • ActiveModel::AttributesͰΘΕ͍ͯΔΤϯ ςΟςΟΫϥε
Callbacks • ActiveModel::Validationsʹinclude͞ΕͯΔ • ͳͷͰɺinclude ActiveModel::ModelͰOK
Attribute_assignment • ActiveModel::Modelʹؚ·ΕΔ • assign_attributesϝιουΛఏڙ
Attribute • Attribute_setͰར༻͞Ε͍ͯΔΫϥε
Secure_password
Conversion • ActiveModel::Modelʹؚ·ΕΔ • ୯ମͰར༻͢Δ͜ͱͳͦ͞͏?
Naming • ActiveModel::Modelʹؚ·ΕΔ • ୯ମͰར༻͢Δ͜ͱͳͦ͞͏?
Serialization • ActiveModel::Serializers::JSONʹؚ·ΕΔ • serializable_hashϝιου͕ར༻ՄʹͳΔ • ୯ମͰΘͳ͍? ͏?
ActiveModel::Translation • ActiveModel::Modelʹؚ·ΕΔ • human_attribute_nameϝιουΛఏڙ
Forbidden_attributes_protection • ͝ΊΜͳ͍͞ ϝϞɿ ࢿྉ࡞͕ؒʹ߹Θͳ͔ͬͨͷͰɺௌऺʹ͍͔͚ͯΓΔɻ μϝͩͬͨΒ॓ͱͯ࣋ͬͯ͠ؼͬͯΒ͏ʢΈͳ͞Μʹʣ
ActiveModel::Lint • ͝ΊΜͳ͍͞
ActiveModel::Railtie • ͝ΊΜͳ͍͞
ActiveModel::Type • ͝ΊΜͳ͍͞
͜ΜͲͦ݁͜
None
We Are Hiring
ActiveModel::Thanks