RailsConf 2022 - Reflecting on Active Record Associations by Daniel Colson

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • Active Record associations seem magical-add a has_many here, a belongs_to there, and suddenly your models are loaded with behavior. Could it be magic, or is it plain old Ruby with some thoughtful design and a bit of metaprogramming? In this talk we'll study Active Record associations by writing our own belongs_to and has_many macros. We'll dynamically define methods, cache query results, replace a a Relation with a CollectionProxy, and automatically prevent N+1 queries with inverses. You'll leave with a deeper understanding of associations, and a new appreciation for their magic.
    _____________________________________________________________
    Cloud 66 - Deploy your Rails code directly from your repo to any cloud in minutes. Cloud 66 offers the convenience of Heroku, but on any cloud and in any region, with persistent storage, custom network configuration, zero downtime deployments, blue/green and canary releases, WAF, and more.
    Get $100 Cloud 66 Free Credits with the code: RailsConf2022
    ($100 Cloud 66 Free Credits, for the new user only, valid till 31st December 2022)
    Cloud 66: cloud66.com/fr...

КОМЕНТАРІ • 4

  • @DanDanilyuk
    @DanDanilyuk Рік тому +3

    Great talk. Bonus points for making it hilarious.

  • @FF-ne2qz
    @FF-ne2qz 2 роки тому +7

    Daniel, thank you very much for this presentation. That was the only one I was waiting for and it helped a lot.

  • @een_schildpad
    @een_schildpad Рік тому +2

    Awesome talk!!! I've always struggled to understand things like collection proxies and how it all works together, so it was fun to see it deconstructed in a way that was simpler to comprehend 🎉

  • @ankk98
    @ankk98 Рік тому +1

    So many great concepts explained so well.
    I will watch a few more times and try to implement these concepts in a case where rails magic is needed.