简体   繁体   English

我在 Rails 中的哪里放置后端服务代理?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM