为模型构建可使用的 uri/url (rails/datamapper/SOA)

发布于 2024-10-17 00:04:00 字数 411 浏览 4 评论 0原文

也许你可以帮助我更详细地思考这个问题。

我需要为模型实例构建或提供一个 uri,该实例可以由另一个应用程序引用或使用,该应用程序可能是也可能不是 Rails 应用程序。

例如,

我创建一个包含内容的标准帖子;我想为该帖子构建一个 URL,另一个应用程序可以通过查看数据库中的模型(或其他不太粘性的方式)来使用或引用。 Datamapper 有一个 URI 字段,我想构建一个规范的 uri,将其存储在那里,并让另一个应用程序能够访问、宣布、操作等。

基本上,我有几个可能位于不同位置的应用程序,需要访问相同的模型,用模型做不同的事情。我需要一种方法来清楚地实现这一点,而不是将它们全部放在一个巨大的应用程序中。

我查看了 Pubsubhub、RSS 等,但没有找到我想要做的任何具体示例。我是否需要为应用程序等创建通用 API?

Perhaps you can help me think this through to greater detail.

I need to build or make available a uri for a model instance that can be referenced or used by another application which may or may not be a rails application.

e.g.

I create a standard Post with content; I want to build a URL for that post another application can consume or reference by looking at the model in the database (or another less sticky fashion). Datamapper has a URI field, I want to build a canonical uri, store it there and have another application be able to access, announce, manipulate, etc.

Basically, I have several applications that may be in different places, that need to access the same model, to do differing things with the model. I need a way to make that happen clearly without putting them all in one monster application.

I've looked at Pubsubhub, RSS, etc. but haven't found any concrete examples of what I'm trying to do. Do I need to create an common API for the applications, etc?

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

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

发布评论

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

评论(1

晌融 2024-10-24 00:04:00

DataMapper 在使用现有数据库方面非常灵活。

许多人使用 DataMapper 是因为它可以创建和拆除数据库结构而无需迁移。但是,您不必以这种方式使用它。

我已经成功地使用了中央“管家”应用程序拥有的大量模型,然后在单独的“界面”应用程序中声明了相同模型的一小部分。

需要进行一些尝试和错误才能找出有效的方法,但它肯定可以做到。我建议将您的模型放入模块中,并在可能的情况下将它们包含在应用程序中。

最后一点,听起来您希望 URI/URL 成为主要接口。如果是这种情况,我强烈建议你看看 Sinatra。它完全以 URL 为导向(我发现 Rails 路由非常迟钝)。

DataMapper is very flexible about using existing databases.

Many people come to DataMapper because it can create and tear down the database structures without migrations. However, you do not have to work with it in that way.

I have had good success with using a large set of models owned by a central 'housekeeping' app and then declaring a small subset of the same models in separate 'interface' apps.

Some trial and error is required to figure out what works but it can certainly be done. I'd suggest putting your models in modules and including them across apps if possible.

A final point it sounds like you want URIs/URLs to be the primary interface. If that is the case I strongly suggest you look at Sinatra. It is entirely oriented around URLs (and I find Rails routes very obtuse).

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