Search code examples
ruby-on-railsrubyjsonapiencapsulation

How can I access data from a Ruby on Rails application externally?


I'm trying to work with the data in my Rails application from within a separate Ruby script.

I read this forum post in which some people suggest that the best way to work with your data is to encapsulate the database within one application, and then have this application provide an API for working with that data. Because it's apparently bad to integrate your database into several different applications.

Well, now I want to work with some data from my Rails app from another script, but on the same system. How can I achieve this?

I might want to work with the data from my Rails app remotely in the future, but also from a script. I'm assuming this might require JSON or SOAP, but I would like to know before I go researching it.


Solution

  • Have you take a look at ActiveResource? It's specifically designed to expose data from a Rails model to another Rails app over HTTP.