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 开发者_StackOverflow社区the best way to solve the task? web-service or some other solution for this? Thank you and best regards!
- 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
. - 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.
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:
- In the source Rails apps, set up your data using scaffolding (generate scaffold).
- 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
精彩评论