简体   繁体   中英

Communication between two rails applicarions

I have two Rails applications. One is like web store and the other is like delivery service app.

I want to create something like this: User goes to web store, buys some stuff. If this person wants these items to be delivered to his house, he fills the order form and the delivery service app receives information from web store with the delivery address.

Can anyone tell me what would be the best way to do that? If possible, maybe give some examples.

One option would be to expose your application as a web service. There is a great chapter about how to do this in the rails recipes book.

Another good option would be to use JSON. From your store website you can post JSON to the service app, and in the service app you can read the JSON as a parameter hash.

If a customer bought a product, will he choose not to deliver? The features of the two apps are so dependent that I see no reason you should have two.

If you plan to grow the second app to a platform that accept lots of such delivering requests from several apps of yours and external owners, you can go further to turn the second app into a RESTful service.

If you don't have such plan, better to integrate them into one app.

Current thinking is that usually the best way for two web apps to communicate is using RESTful interfaces that pass data in JSON format. Rails is built to support this by default alongside HTML based interfaces for users using web browsers. With this architecture, other applications can use the web app in a manner very similar to users using browsers but optimized for data interchange.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM