I recently came across Robert Martin's (Uncle Bob) keynote on how to structure a rails app based on use-cases. I found this very interesting.
Here is the link to the keynote: Architecture: the Lost Years
Here is a sample project that structures the app based on the principles mentioned by Robert Martin in his keynote: Guru Watch
I was wondering if there were well established rails applications out there that are structured in such fashion (Use Case Driven Approach / Entity-Control-Boundary architecture / decoupling back end from front-end)
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.
来源:https://stackoverflow.com/questions/14194988/rails-apps-that-decouple-activerecord-from-business-logic