views:

47

answers:

1

I have a Rudy on Rails backend which I use because it has some libraries that other languages don't have. I'm trying to use it as a web service/backend and accept requests from PHP/general HTTP request pages. It should be very simple - hopefully, accept a JSON object and respond with a JSON object. Rails seems to default to a RJS/ non-standard client side request.

Ideally, I'd have a php generated jquery/html page send a JSON object to a ruby on rails page and have the ruby on rails page respond with a different JSON object.

Obviously, I'm not very familiar with Rails, but I would like to use it. I know it isn't a good idea to attempt to integrate Ruby on Rails with PHP. In essence, I'd like to run ruby simply as a web service for the same purpose.

I suppose in the abstract, this would be how to integrate rails as a backend with other client side technologies.

Thanks for all the help.

A: 

If you're using Apache I would recommend you to serve those application from different VirtualHosts. For example, you can have:

  • PHP based website => www.example.com
  • Rails Web Service => service.example.com/wsdl

This will allow you to isolate PHP and Ruby configurations and you'll avoid conflicts between them.

The communication between apps will be made as usual.

If you have any question regarding Apache or VirtualHost you can ask in Server Fault or read some great tutorials at Slicehost or Linode Library

fjuan
This _may_ end up giving you headaches with same-origin issues, if you are calling the ROR system via Javascript sent to the client from the PHP system... something to be careful about.
Brian
I can't see a JS "same-origin" issue because you're accessing each of them with a different URL, although both applications are served by the same Apache instance,
fjuan