Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Little Engines That Could

The Little Engines That Could

Rails Engines. It’s more than just a cute name made up of two words both related to trains.

Are they plug-ins? Are they gems? When do we use them? How do we implement them? Why aren’t they used more often?

Those are the questions I wish were answered for me when I first learned about Rails Engines. Inspired by Wired’s Explain In 5 Levels series, we will explore Rails Engines and address these quandaries using a variety of techniques, breaking down what engines are and how and when to use them.

Mina Slater

May 24, 2022
Tweet

Other Decks in Programming

Transcript

  1. The Little Engines That Could
    RailsConf 2022
    🚂

    View full-size slide

  2. 👋 👋 👋
    She/her


    Rails Developer


    : @minar528
    Hi! I’m Mina!

    View full-size slide

  3. The Little Engines That Could
    RailsConf 2022
    Three ways to understanding
    🚂

    View full-size slide

  4. @minar528
    RailsConf 2022 @minar528
    💭

    View full-size slide

  5. @minar528
    RailsConf 2022
    🤨

    View full-size slide

  6. @minar528
    RailsConf 2022
    🚂 👀

    View full-size slide

  7. @minar528
    RailsConf 2022
    🎉
    🚂

    View full-size slide

  8. @minar528
    RailsConf 2022
    🎙

    View full-size slide

  9. @minar528
    RailsConf 2022
    🔎

    View full-size slide

  10. RailsConf 2022 @minar528

    View full-size slide

  11. RailsConf 2022 @minar528
    🤹

    View full-size slide

  12. RailsConf 2022 @minar528
    🤹

    View full-size slide

  13. RailsConf 2022 @minar528
    🤹

    View full-size slide

  14. 🤹
    RailsConf 2022 @minar528
    What is an engine?


    What are its bene
    f
    its?

    View full-size slide

  15. 🤹
    RailsConf 2022 @minar528
    What is an engine?


    What are its bene
    f
    its?
    What makes it unique?


    Types of engines?

    View full-size slide

  16. 🤹
    RailsConf 2022 @minar528
    How to implement?


    How to test?


    What is an engine?


    What are its bene
    f
    its?
    What makes it unique?


    Types of engines?

    View full-size slide

  17. @minar528
    RailsConf 2022 @minar528
    @minar528
    Level One
    Non-Technical

    View full-size slide

  18. RailsConf 2022 @minar528
    🕵

    View full-size slide

  19. RailsConf 2022 @minar528
    🚂
    🕵

    View full-size slide

  20. RailsConf 2022 @minar528
    🕵 🚂

    View full-size slide

  21. @minar528
    RailsConf 2022

    View full-size slide

  22. RailsConf 2022 @minar528

    View full-size slide

  23. RailsConf 2022 @minar528

    View full-size slide

  24. @minar528
    RailsConf 2022
    Cannot operate alone
    Both need hosts

    View full-size slide

  25. @minar528
    RailsConf 2022
    Provides "superpowers"
    Both enhance their hosts

    View full-size slide

  26. @minar528
    RailsConf 2022
    Multiple Hosts
    Both can integrate with and adapt to di
    ff
    erent hosts

    View full-size slide

  27. RailsConf 2022 @minar528
    Groot Rocket Drax

    View full-size slide

  28. RailsConf 2022 @minar528
    🕵

    View full-size slide

  29. @minar528
    RailsConf 2022
    Reusable
    Client wants to share the engine

    View full-size slide

  30. @minar528
    RailsConf 2022
    Reduce scope
    Client wants to split up the system

    View full-size slide

  31. @minar528
    RailsConf 2022
    Shorten test time
    Client wants to cut their test execution time

    View full-size slide

  32. 🤹
    RailsConf 2022 @minar528
    How to implement?


    How to test?


    What is an engine?


    What are its bene
    f
    its?
    What makes it unique?


    Types of engines?

    View full-size slide

  33. 🤹
    RailsConf 2022 @minar528
    How to implement?


    How to test?


    What is an engine? ✅


    What are its bene
    f
    its?
    What makes it unique?


    Types of engines?

    View full-size slide

  34. 🤹
    RailsConf 2022 @minar528
    How to implement?


    How to test?


    What is an engine? ✅


    What are its bene
    f
    its? ✅
    What makes it unique?


    Types of engines?

    View full-size slide

  35. @minar528
    RailsConf 2022 @minar528
    @minar528
    Level Two
    Early-Career Devs

    View full-size slide

  36. RailsConf 2022 @minar528

    View full-size slide

  37. RailsConf 2022 @minar528

    View full-size slide

  38. RailsConf 2022 @minar528
    🚂 🚄
    vs.

    View full-size slide

  39. RailsConf 2022 @minar528
    Rails::Application


    Rails::Engine
    🚂 🚄
    vs.
    🚂 🚄
    vs.

    View full-size slide

  40. RailsConf 2022 @minar528
    Rails::Application < Rails::Engine
    Rails::Engine


    🚂 🚄
    vs.
    🚂 🚄
    vs.

    View full-size slide

  41. RailsConf 2022 @minar528
    Rails::Application < Rails::Engine


    Also MVC


    Rails::Engine


    MVC


    🚂 🚄
    vs.
    🚂 🚄
    vs.

    View full-size slide

  42. RailsConf 2022 @minar528
    Rails::Application < Rails::Engine


    Also MVC


    Runs independently


    Rails::Engine


    MVC


    🚂 🚄
    vs.
    🚂 🚄
    vs.

    View full-size slide

  43. RailsConf 2022 @minar528
    Rails::Application < Rails::Engine


    Also MVC


    Runs independently


    Rails::Engine


    MVC


    Nope.


    🚂 🚄
    vs.
    🚂 🚄
    vs.

    View full-size slide

  44. RailsConf 2022 @minar528
    Rails::Application < Rails::Engine


    Also MVC


    Runs independently


    Gem
    f
    ile
    Rails::Engine


    MVC


    Nope.


    gemspec
    🚂 🚄
    vs.
    🚂 🚄
    vs.

    View full-size slide

  45. RailsConf 2022 @minar528
    🚂 💎
    vs.

    View full-size slide

  46. RailsConf 2022 @minar528
    💎
    Packaged and published


    🚂 vs.
    🚂 vs.

    View full-size slide

  47. RailsConf 2022 @minar528
    💎
    Packaged and published


    CAN be packaged and published


    🚂 vs.
    🚂 vs.

    View full-size slide

  48. RailsConf 2022 @minar528
    💎
    Packaged and published


    CAN be packaged and published


    Rails only
    🚂 vs.
    🚂 vs.

    View full-size slide

  49. RailsConf 2022 @minar528
    💎
    Packaged and published


    Any Ruby project


    CAN be packaged and published


    Rails only
    🚂 vs.
    🚂 vs.

    View full-size slide

  50. RailsConf 2022 @minar528
    🚂 🔌
    vs.

    View full-size slide

  51. RailsConf 2022 @minar528
    🔌
    Subset of 🔌
    🚂 vs.
    Includes 🚂

    View full-size slide

  52. RailsConf 2022 @minar528
    🔌
    Subset of 🔌


    Use with Rails
    🚂 vs.
    Includes 🚂


    Use with Rails

    View full-size slide

  53. RailsConf 2022 @minar528
    Rails Guides
    “An engine CAN be a plugin,


    and a plugin CAN be an engine.”

    View full-size slide

  54. @minar528
    RailsConf 2022

    View full-size slide

  55. RailsConf 2022 @minar528
    My PR to Rails documentation
    “All engines are plugins,


    but not all plugins are engines.”

    View full-size slide

  56. RailsConf 2022 @minar528
    🔌
    Subset of 🔌


    Use with Rails


    MVC
    🚂 vs.
    Includes 🚂


    Use with Rails


    View full-size slide

  57. RailsConf 2022 @minar528
    🔌
    Subset of 🔌


    Use with Rails


    MVC
    🚂 vs.
    Includes 🚂


    Use with Rails


    Model-level modi
    f
    ications


    View full-size slide

  58. RailsConf 2022 @minar528
    🔌
    Subset of 🔌


    Use with Rails


    MVC


    🚂 vs.
    Includes 🚂


    Use with Rails


    Model-level modi
    f
    ications


    View full-size slide

  59. RailsConf 2022 @minar528

    View full-size slide

  60. RailsConf 2022 @minar528

    View full-size slide

  61. 🤹
    RailsConf 2022 @minar528
    How to implement?


    How to test?


    What makes it unique?


    Types of engines?
    What is an engine? ✅


    What are its bene
    f
    its? ✅

    View full-size slide

  62. 🤹
    RailsConf 2022 @minar528
    How to implement?


    How to test?


    What makes it unique? ✅


    Types of engines?
    What is an engine? ✅


    What are its bene
    f
    its? ✅

    View full-size slide

  63. 🤹
    RailsConf 2022 @minar528
    How to implement?


    How to test?


    What makes it unique? ✅


    Types of engines? ✅
    What is an engine? ✅


    What are its bene
    f
    its? ✅

    View full-size slide

  64. @minar528
    RailsConf 2022 @minar528
    @minar528
    Level Three
    Rails Devs New To Engines

    View full-size slide

  65. RailsConf 2022 @minar528

    View full-size slide

  66. RailsConf 2022 @minar528

    View full-size slide

  67. RailsConf 2022 @minar528

    View full-size slide

  68. RailsConf 2022 @minar528

    View full-size slide

  69. RailsConf 2022 @minar528

    View full-size slide

  70. RailsConf 2022 @minar528

    View full-size slide

  71. RailsConf 2022 @minar528

    View full-size slide

  72. RailsConf 2022 @minar528

    View full-size slide

  73. RailsConf 2022 @minar528

    View full-size slide

  74. RailsConf 2022 @minar528

    View full-size slide

  75. RailsConf 2022 @minar528

    View full-size slide

  76. RailsConf 2022 @minar528

    View full-size slide

  77. RailsConf 2022 @minar528

    View full-size slide

  78. RailsConf 2022 @minar528

    View full-size slide

  79. RailsConf 2022 @minar528

    View full-size slide

  80. RailsConf 2022 @minar528

    View full-size slide

  81. RailsConf 2022 @minar528

    View full-size slide

  82. RailsConf 2022 @minar528

    View full-size slide

  83. @minar528
    RailsConf 2022
    🎉

    View full-size slide

  84. RailsConf 2022 @minar528

    View full-size slide

  85. RailsConf 2022 @minar528

    View full-size slide

  86. 🤹
    RailsConf 2022 @minar528
    How to implement?


    How to test & mount?


    What makes it unique? ✅


    Types of engines? ✅
    What is an engine? ✅


    What are its bene
    f
    its? ✅

    View full-size slide

  87. 🤹
    RailsConf 2022 @minar528
    How to implement? ✅


    How to test & mount?


    What makes it unique? ✅


    Types of engines? ✅
    What is an engine? ✅


    What are its bene
    f
    its? ✅

    View full-size slide

  88. 🤹
    RailsConf 2022 @minar528
    What makes it unique? ✅


    Types of engines? ✅
    What is an engine? ✅


    What are its bene
    f
    its? ✅
    How to implement? ✅


    How to test & mount? ✅


    View full-size slide

  89. @minar528
    RailsConf 2022
    🚂 💕

    View full-size slide

  90. @minar528
    RailsConf 2022
    RailsConf 2023?

    View full-size slide

  91. RailsConf 2022 @minar528
    🚂 🧰
    🛤

    View full-size slide

  92. RailsConf 2022 @minar528
    🚂
    🧰
    🛤

    View full-size slide

  93. RailsConf 2022 @minar528
    THANK YOU! 🥰
    🖋 http://minaslater.blog


    🎙 “Your TDD Treasure Map” - Aji Slater


    🎙 “Come On In! Making Yourself At Home In A New Codebase” -
    Mercedes Bernard

    View full-size slide