ぼくが考える最強のApplicationModel @表参道.rb #43

586a2d464eed3c7e5dd809d6fe0269d7?s=47 YABOO JAPAN
February 07, 2019
400

ぼくが考える最強のApplicationModel @表参道.rb #43

586a2d464eed3c7e5dd809d6fe0269d7?s=128

YABOO JAPAN

February 07, 2019
Tweet

Transcript

  1. ΅͕͘ߟ͑Δ࠷ڧͷ ApplicationModel @yaboojp on Omotesando.rb #43 2019/2/6

  2. Self • Name: େ༅ Ӭ / @yaboojp • Jobs: •

    22Inc. Co-Founder & CTO @த໨ࠇ • ex NTTdata @ங஍ʙ๛ऱ • Location: ژ౎ -> ౦ژ • Favorites: Ϗʔϧ, Իָ, όΠΫ, JALϚΠϧ
  3. None
  4. ActiveRecord͡Όͳ͍ ModelઃܭͲ͏ͯ͠·͔͢ʁ

  5. ฐࣾ • جຊతʹ͸ɺActiveModelύλʔϯ • PORO(Plain Old Ruby Object)ͰStructΛར༻ ͢Δͷ΋ྑͦ͞͏ͱࢥ͍ͭͭ •

    ActiveModel::Attributes͕Rails5.2͔Β࢖͑Δ ͷͰ΍ͬͺΓActiveModel͕ྑͦ͞͏
  6. ActiveModel::Attributes

  7. ౰ॳ LT͠Α͏ͱͯͨ͠ωλ • not Rails 5.2

  8. ActiveModel::DirtyͰมߋݕ஌

  9. ɹʊਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹɹɹɹɹɹɹɹɹɹɹɹʻ ʼɹ ࿩͢ωλ͕ͳ͘ͳͬͨ ɹʻ ʼɹɹɹɹɹɹɹɹɹɹɹɹʻ ɹʉY^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ʉ

  10. ౰ॳ LT͠Α͏ͱͯͨ͠ωλ • Rails 5.2Ҏ߱Ͱ͸ෆཁͳϋοΫ

  11. ݁࿦

  12. Thanks

  13. Thanks

  14. None
  15. None
  16. Ͳ͏ͯ͜͠͏ͳͬͨʁ

  17. ແବ ແବ ແବ ແବ

  18. ActiveModelͷؾ࣋ͪʹͳΔ

  19. None
  20. ૯౰ͨΓͷମ౰ͨΓ

  21. Model

  22. Attributes

  23. Dirty

  24. Serializers::JSON • API࣮૷ͰΑ͘࢖ΘΕͯΔ • ::XMLͱ͔ଞͷϑΥʔϚοτ͸ͳ͔ͬͨ • ActiveModel::SerializationΛؚΉ

  25. Validations • ActiveModel::Modelʹؚ·ΕΔ

  26. Validator • ActiveModel::Modelʹؚ·ΕΔ

  27. Attribute_methods • ActiveModel::Attributesʹinclude͞ΕͯΔ • prefix/suffix෇͖ͷڞ௨ϝιουΛ֤attribute ʹఆٛͰ͖Δ • ಺෦࣮૷͸ɺmethod_missingࠇຐज़

  28. Attribute_mutation_tracker • ActiveModel::DirtyͰ࢖ΘΕ͍ͯΔΤϯςΟ ςΟΫϥε

  29. Attribute_set • ActiveModel::AttributesͰ࢖ΘΕ͍ͯΔΤϯ ςΟςΟΫϥε

  30. Callbacks • ActiveModel::Validationsʹinclude͞ΕͯΔ • ͳͷͰɺinclude ActiveModel::ModelͰOK

  31. Attribute_assignment • ActiveModel::Modelʹؚ·ΕΔ • assign_attributesϝιουΛఏڙ

  32. Attribute • Attribute_setͰར༻͞Ε͍ͯΔΫϥε

  33. Secure_password

  34. Conversion • ActiveModel::Modelʹؚ·ΕΔ • ୯ମͰར༻͢Δ͜ͱ͸ͳͦ͞͏?

  35. Naming • ActiveModel::Modelʹؚ·ΕΔ • ୯ମͰར༻͢Δ͜ͱ͸ͳͦ͞͏?

  36. Serialization • ActiveModel::Serializers::JSONʹؚ·ΕΔ • serializable_hashϝιου͕ར༻ՄʹͳΔ • ୯ମͰ͸࢖Θͳ͍? ࢖͏?

  37. ActiveModel::Translation • ActiveModel::Modelʹؚ·ΕΔ • human_attribute_nameϝιουΛఏڙ

  38. Forbidden_attributes_protection • ͝ΊΜͳ͍͞ ϝϞɿ ࢿྉ࡞੒͕ؒʹ߹Θͳ͔ͬͨͷͰɺௌऺʹ໰͍͔͚ͯ৐Γ੾Δɻ μϝͩͬͨΒ॓୊ͱͯ࣋ͬͯ͠ؼͬͯ΋Β͏ʢΈͳ͞Μʹʣ

  39. ActiveModel::Lint • ͝ΊΜͳ͍͞

  40. ActiveModel::Railtie • ͝ΊΜͳ͍͞

  41. ActiveModel::Type • ͝ΊΜͳ͍͞

  42. ͜ΜͲͦ݁͜࿦

  43. None
  44. We Are Hiring

  45. ActiveModel::Thanks