Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

The ease of PHP with the power of Ruby

By Peter Cooper / August 27, 2006

#!/usr/bin/ruby                                                                 
require 'rubyhp'
__END__
<html>
 <body>
  <% cgi.params.each do |key, value| %>
   <%= key %>: <%= value %><br />
  <% end %>
  <% if cgi.params.empty? %>
   Sorry, please enter some cgi parameters. How about "?foo=baz"?
  <% end %>
 </body>
</html>

Christopher Cyll has put together a great little example of how to quickly create templated Web pages with Ruby without requiring any frameworks. It relies on CGI, but sometimes that's all you need, and it makes throwing together tiny Ruby-powered Web pages possible as easy as creating a simple PHP page.

Comments

  1. AnĂ­bal Rojas says:

    What about:

    http://www.hiveminds.co.uk/node/3105

    It is a little bit more elaborated, but almost the same. And I agree with you, not everything is a "application" there is a lot of space for quick n' dirty small scripts

  2. Christoffer Sawicki says:

    A slightly better way:
    http://termos.vemod.net/making-ruby-into-php-take-two

  3. James says:

    One of the things I like about Ruby's Nitro Web framework is that it makes it very easy to build dirt-simple, ASP/PHP-like pages, while providing a good migration path to more a sophisticated ORM/MVC-style architecture if you need that as the application evolves.

    http://nitroproject.org/

Other Posts to Enjoy

Twitter Mentions