7

I have built two rails apps that need to communicate and send files between each other. For example one rails app would send a request to view a table in the other apps' database. The other app would then render json of that table and send it back. I would also like one app to send a text file stored in its public directory to the other app's public directory.

I have never done anything like this so I don't even know where to begin. Any help would be appreciated. Thanks!

5 Answers 5

5

You requirement is common for almost all the web apps irrespective of rails, Communicating with each other is required by most modern web apps. But there is a small understanding that you need to get hold on,

Web sites should not directly access each others internal data (such as tables), (even if they are build by the same language (in this case Rails) by the same developer),

That is where the web-services comes in to play, So you should expose your data through web services so that not only rails application can consume that, but also any app that knows how to consume a web service will get benefit.

Coming back to your question with Rails, rails supports REST web services out of the box, So do some googling about web services, REST web services with rails

HTH

2

As a starting point, look at ActiveResource.

Railscast

docs

3
  • 2
    ActiveResource is more or less deprecated. Starting with Rails 4.0, it will be not standard part of Rails anymore. And unless somebody steps up to maintaining it, it will be gone for good... Apr 23, 2012 at 20:27
  • Ah, that's too bad. At least the idea is decent enough, so hopefully it provides a starting point. Mainly, you want one Rails app providing a RESTful interface to the world, and then the other app just happens to use that interface to get the data that it needs.
    – jdl
    Apr 23, 2012 at 21:22
  • 2st link returns a 404.
    – Alan
    Dec 21, 2013 at 16:59
1

Message queuing systems such as RabbitMQ may be used to communicate things internally between different apps such as a "mailer" app and a main "hub" application.

Alternatively, you can use a shared connection to something like redis stick things onto a "queue" in one app and read them for processing from the other.

0

In recent Rails versions, it is rather easy to develop API only applications. In the Rails core master, there was even a special application type for these apps briefly (until it got yanked again). But it is still available as a plugin and probably one day becomes actually part of Rails core again. See http://blog.wyeworks.com/2012/4/20/rails-for-api-applications-rails-api-released for more information.

To actually develop and maintain the API of the backend service and make sure both backend and frontend have the same understanding of the resources, you can use ROAR which is great way to build great APIs.

Generally, you should fully define your backend application with an API. Trying to be clever and to skip some of the design steps will only bring you headaches in the long run...

1
0

Check out Morpheus. It lets you create RESTful services and use familiar ActiveRecord syntax in the client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.