在多个轨道应用程序之间传输数据

发布于 2024-10-07 05:08:59 字数 162 浏览 0 评论 0原文

现在我有一个任务要做,任务如标题所示,现在我应该创建一个 Rails 应用程序以从其他四个 Rails 应用程序获取数据。我应该为 Rails 应用程序制作接口,这样我的新 Rails 应用程序就可以从其他应用程序获取数据。我该怎么办?解决任务的最佳方法是什么?网络服务或其他解决方案?谢谢您并致以诚挚的问候!

Now i have a task to do,the task is as the title said, now i should crate a rails application to get the data from the other four rails application. i should make the interface for the rails application ,so my new rails application can get the data from the others. how should i do? what is the best way to solve the task? web-service or some other solution for this? Thank you and best regards!

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

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

发布评论

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

评论(2

那一片橙海, 2024-10-14 05:08:59
  1. 您可以在所有其他四个 Rails 应用程序中创建一个控制器方法,以便这个新的 Rails 应用程序可以使用 XMLHttpRequest 调用它。
  2. 或者,您可以使用一个通用数据库来放入数据,并让其他四个 Rails 应用程序轮询该数据库以检查是否有可用的新数据。
  1. You can create a controller method inside all the other four rails apps so it can be called by this new rails app using XMLHttpRequest.
  2. Or you can have one common database to put in the data, and let the the other four rails apps polls to the database to check if there is new data available.
2024-10-14 05:08:59

答案是“这取决于情况”。为了确定下来,您需要了解的信息是:

  • 您需要多久传输一次数据?
  • 数据是文本还是二进制?
  • 我们谈论的是多少数据?

但最快、最简单的方法(足以让您入门)是使用 Rails 的内置 REST 功能:

  1. 在源 Rails 应用程序中,使用脚手架(生成脚手架)设置数据。
  2. 在接收 Rails 应用程序中,通过将源设置为活动资源来连接到源。请参阅http://api.rubyonrails.org/classes/ActiveResource/Base.html

The answer is, "it depends." Info you'd need to know in order to nail it down is:

  • How often do you need to transfer the data?
  • Is the data text or binary?
  • How much data are we talking about?

But the fastest and easiest way to do this, which will be enough to get you started, is to use the built-in REST features of Rails:

  1. In the source Rails apps, set up your data using scaffolding (generate scaffold).
  2. In the receiving Rails app, connect to the sources by setting them up as active resources. See http://api.rubyonrails.org/classes/ActiveResource/Base.html
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文