我应该将后端服务代理放在 Rails 中的什么位置?

发布于 2024-11-24 07:56:37 字数 100 浏览 4 评论 0原文

我的控制器需要通过 HTTParty 与后端服务通信。您会将服务代理类放在哪里?

我想我会为此创建一个 /app/services 文件夹,但我想知道是否有更惯用的东西?

My controller needs to talk to a back-end service via HTTParty. Where would you put that service proxy class?

I was thinking I would create an /app/services folder for this, but I was wondering if there was something more idiomatically appropriate?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青芜 2024-12-01 07:56:37

我将我的放在 app/models 中,但如果您愿意,app/services 似乎也合适。

I put mine in app/models, but app/services seems appropriate as well if you prefer.

痴者 2024-12-01 07:56:37

我会将其存储在 lib 文件夹中(可能在 lib/services 中?),然后在必要时需要它。

我相信这将是存储它的“Rails place”......

I would store it within the lib folder (possibly in lib/services ?) and then require it where necessary.

I believe this would be the "Rails place" to store it...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文