Main Content

Ruby at both extremes of your website

Archive - Originally posted on "The Horse's Mouth" - 2011-09-10 19:37:06 - Graham Ellis

Q: How is Ruby used on the web?

A: At both extremes.

Here's a web server ... serving documents and programs (on the right) to browsers (on the left).


On the server, here is Ruby on a Rails Framework on the right. Requests to the Web Server are passed to the routing section of Rails, then routed to the appropriate controller. The controller accesses data from the model, and passes it to the view, from which the response is returned.

Ruby can also be used through the Common Gateway Interface - there's a standard CGI class, and we've got a "hello world" source example [here] on our web site. The CGI module includes header handling, forms, data escaping functionallity, cookies and sessions.


Beyond the client, here are Watir and Selenium ... and Cucumber too. They're not used to generate web pages - their used to test a web site, running that site via a browser to a programmed test pattern.

There is also a standard net/HTTP module which provides programs with the ability to make use of web resources via what is in effect a browser written in Ruby. There's an example of that in use here on our web site. the net/HTTP module includes a wide range of data and method handlers to support both GET and POST method request gnereation, simple authentication, and response handling.


Read the next article about Ruby for web site testing here

Read the next article about Ruby as a server language in the Rails framework here