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
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
1
1.3k
Product Roadmaps are Hard
iamctodd
43
9.7k
How STYLIGHT went responsive
nonsquared
92
4.8k
Ruby is Unlike a Banana
tanoku
96
10k
Become a Pro
speakerdeck
PRO
10
4.5k
Making the Leap to Tech Lead
cromwellryan
123
8.5k
How to name files
jennybc
64
92k
How to train your dragon (web standard)
notwaldorf
72
5.1k
Happy Clients
brianwarren
91
6.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
273
13k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
Documentation Writing (for coders)
carmenintech
59
3.9k
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