[英]Where do I put back-end service proxies in Rails?
My controller needs to talk to a back-end service via HTTParty.我的 controller 需要通过 HTTParty 与后端服务通信。 Where would you put that service proxy class?
您会将服务代理 class 放在哪里?
I was thinking I would create an /app/services folder for this, but I was wondering if there was something more idiomatically appropriate?我在想我会为此创建一个 /app/services 文件夹,但我想知道是否有更惯用的东西?
I put mine in app/models
, but app/services
seems appropriate as well if you prefer.我把我的放在
app/models
中,但如果你愿意, app/services
似乎也很合适。
I would store it within the lib
folder (possibly in lib/services
?) and then require it where necessary.我会将它存储在
lib
文件夹中(可能在lib/services
中?),然后在必要时需要它。
I believe this would be the "Rails place" to store it...我相信这将是存储它的“Rails 地方”......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.