# Learning to work with HTTP using RoR

**URL:** <https://www.ruby-forum.com/t/learning-to-work-with-http-using-ror/177961>\
**Category:** Rails\
**Created:** [October 27, 2009, 9:29am UTC](https://www.ruby-forum.com/t/learning-to-work-with-http-using-ror/177961 "2009-10-27T09:29:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasonallen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@jasonallen](https://www.ruby-forum.com/u/jasonallen)\
**Post date:** [October 27, 2009, 9:29am UTC](https://www.ruby-forum.com/t/learning-to-work-with-http-using-ror/177961/1 "2009-10-27T09:29:54Z")

</div>

im trying to learn how to handle http  
here is the scenario:

[www.mysite.com](http://www.mysite.com) performs an HTTParty.post to [www.2ndsite.com](http://www.2ndsite.com)  
[www.2ndsite.com](http://www.2ndsite.com) processes the data  
[www.2ndsite.com](http://www.2ndsite.com) will post back to [www.mysite.com](http://www.mysite.com) the resulting data

here are the questions that i have:  
is there any difference in the way to handle the incoming data? (im  
used mainly to internal object to object communication, so my worry is  
iba yung way of handling the data)  
can you guys suggest literature to read on how to learn on about this  
issue.

thank you in advance!!!

---

<div class="post-metadata">

**Author:** ![jasonallen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@jasonallen](https://www.ruby-forum.com/u/jasonallen)\
**Post date:** [October 27, 2009, 5:37pm UTC](https://www.ruby-forum.com/t/learning-to-work-with-http-using-ror/177961/2 "2009-10-27T17:37:35Z")

</div>

Jason Agujo wrote:

> im trying to learn how to handle http  
> here is the scenario:
> 
> [www.mysite.com](http://www.mysite.com) performs an HTTParty.post to [www.2ndsite.com](http://www.2ndsite.com)  
> [www.2ndsite.com](http://www.2ndsite.com) processes the data  
> [www.2ndsite.com](http://www.2ndsite.com) will post back to [www.mysite.com](http://www.mysite.com) the resulting data
> 
> here are the questions that i have:  
> is there any difference in the way to handle the incoming data? (im  
> used mainly to internal object to object communication, so my worry is  
> iba yung way of handling the data)  
> can you guys suggest literature to read on how to learn on about this  
> issue.

This is why man invented web services. Rails does a fine job of  
providing REST web services. You should start there. Also look at web  
services provides by some of the more popular web applications such as  
Basecamp, Lighthouse, PivotalTracker, etc.

> **[GitHub - basecamp/basecamp-classic-api: Official API documentation for...](https://github.com/basecamp/basecamp-classic-api)**
>
> Official API documentation for Basecamp Classic. Contribute to basecamp/basecamp-classic-api development by creating an account on GitHub.

[http://www.pivotaltracker.com/help/api](http://www.pivotaltracker.com/help/api)  
[http://help.lighthouseapp.com/faqs/api](http://help.lighthouseapp.com/faqs/api)

---

<div class="post-metadata">

**Author:** ![jasonallen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@jasonallen](https://www.ruby-forum.com/u/jasonallen)\
**Post date:** [October 28, 2009, 10:10am UTC](https://www.ruby-forum.com/t/learning-to-work-with-http-using-ror/177961/3 "2009-10-28T10:10:29Z")

</div>

Here is a clean way of doing this on Suse.

in /etc/apache2/httpd.conf make sure there is an include to a  
directory with all of your virtual hosts definitions:

Include /etc/apache2/vhosts.d/\*.conf

then in my /etc/apache2/listen.conf I have (it could go anywhere in  
reality but SUSE puts it in here.) And I am willing to bet that this  
is the part you have missed out if you are still not up and running:

NameVirtualHost \*:80

and as I use Passenger i have the following file: /etc/apache2/  
vhosts.d/passenger.conf

# these are the Apache directived to load the passenger runtime module

for Rails. These are used by the rails virtual hosts

LoadModule passenger\_module /usr/lib64/ruby/gems/1.8/gems/  
passenger-2.2.2/ext/apache2/mod\_passenger.so  
PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.2  
PassengerRuby /usr/bin/ruby  
PassengerUserSwitching off  
PassengerDefaultUser wwwrun

then for each of your virtual hosts put a file in /etc/apache2/  
vhosts.d/example.conf (I redirect [example.com](http://example.com) to [www.example.com](http://www.example.com) for  
which you have to enable the rewrite Apache module)

\<VirtualHost \*:80\>  
ServerName [www.example.com](http://www.example.com)  
ServerAlias [example.com](http://example.com)

RewriteEngine On  
RewriteCond %{HTTP\_HOST} !^www.example.com [NC]  
RewriteCond %{HTTP\_HOST} !^$  
RewriteRule ^/(.\*) [http://www.example.com/$1](http://www.example.com/$1) [L,R]

RailsEnv production  
RailsBaseURI /

```
  <Directory /srv/www/vhosts/example/current/public>
      Options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from All
      </Directory>

    DocumentRoot /srv/www/vhosts/example/current/public

```

ErrorLog /var/log/apache2/example\_production\_error\_log  
TransferLog /var/log/apache2/example\_production\_access\_log  
LogLevel warn

Another simple thing here is that if you rename a example.conf to  
example.conf.disable and do a rcapache2 restart then you can take a  
virtual host off-line.

I did think at one stage at templating this using capistano (and some  
have) but I decided to keep everything in Git. Then it is easy to  
move virtual hosts between servers.

On my setup I am still not happy on where the errors go to (mainly the  
default server error log for some reason) so any ideas out there on  
why this is the case.

O.
