如果我只需要一个数据库和一个 API,那么使用 Sinatra 而不是 RoR 有什么好处

发布于 2025-01-04 20:14:25 字数 306 浏览 2 评论 0原文

我需要为手机游戏构建一个 Web 服务来管理多人游戏的状态。我需要一个数据库和一个 RESTful API 来访问它。我非常熟悉 Ruby On Rails,并且正在考虑使用它,因为我可以很快地将数据库和 API 组合在一起。然而,由于 RoR 是一个用于构建网页的框架,而我实际上并没有构建任何网页,因此即使它可以工作,它自然看起来也是错误的技术。因此,我正在考虑在 Sinatra 上使用 Ruby,但我以前从未使用过它,所以我必须花一些时间来学习它。对于 Ruby 专家来说,对于我想要实现的目标,使用 Sinatra 有优势还是使用 RoR 有劣势?

预先非常感谢您的智慧!

I need to build a web service, for a mobile game, to manage the states of multiplayer games. I need a database and an RESTful API to access it. I'm very familiar with Ruby On Rails and was thinking of using that since I can throw together the DB and API pretty quickly. However, since RoR is a framework for building web pages and I'm not actually building any web pages, it naturally seems like the wrong technology to use even though it would work. As such, I'm considering using Ruby on Sinatra, but I've never used it before and I'll have to kill some time learning it. For you Ruby gurus, is there an advantage to using Sinatra or a disadvantage to using RoR for what I'm trying to accomplish?

Thanks so much in advance for your wisdom!

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

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

发布评论

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

评论(2

我三岁 2025-01-11 20:14:25

你了解 Rails,但你不了解 Sinatra。就我个人而言,我更喜欢后者,比如构建 API,但是没有什么可以阻止你在 Rails 中这样做,而且它本质上也没有什么问题。除非您想将其视为进入 Sinatra 的学习机会,否则我建议您坚持使用 Rails。顺便说一句,这里有一些可能有用的链接:

You know Rails, you don't know Sinatra. Personally I prefer the latter for things like building APIs, but there's nothing stopping you from doing it in Rails, and there's nothing intrinsically wrong with it either. Unless you want to see this as a learning opportunity for getting into Sinatra, I'd say stick with Rails. Here's some links that might be useful btw:

淑女气质 2025-01-11 20:14:25

这可能取决于你的 API。如果您需要的不仅仅是一堆路由,那么您将必须提出自己的解决方案(身份验证,...)。
如果您只需要一些休息而不增加重量,那么 Sinatra 就很棒。您只需要知道在哪条路线上会发生什么就可以了。请参阅 Sinatra 自述文件,其中包含所有入门信息。

It probably depends on your API. If you need more than just a bunch of routes then you will have to come up with your own solutions (authentication, ...).
If all you need is some RESTfulness without the added weight, Sinatra is great. All you need to know is what happens in what route and you're fine. See the Sinatra Readme which has all the information to get started.

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