Do not call external apis etc through active record objects

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the architecture category.

Last Updated: 2023-12-03

Imagine you have the following structure:

controller -> model -> paypal (e.g. hits api through a method here)

This is a bad design because an ActiveRecord model should only be responsible for talking to the DB. It should not be responsible for API stuff wtih PayPal.

A better design would be:

controller -> orchestrator/service -> [paypal_api, model]

In what ways is this better?