Rails apps that decouple ActiveRecord from Business Logic

匆匆过客 提交于 2019-12-03 08:31:47

Well, I can't share the code, but I can point you to some direction. We've been using this gem in our application: https://github.com/collectiveidea/interactor.

I was heavily inspired by Martin's keynote, and this app' development went pretty well :). In case of ActiveRecord and Business Logic separation, we did the following:

Each class in our business logic had somekind of DatabaseEntity counterpart. This counterpart was using another class - our adapter to ActiveRecord. It was querying corresponding ActiveRecord model and converting ActiveRecord instances to instances of our business logic classes.

After all, most of the code was concentrated in this adapter.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!