From: “Gib L.” [email protected]
But what type of things would you use Ruby for within a website? And
would you use HTML for example, to create the structure, or is it all
done in Ruby?
To develop a project of any significant size, you’ll probably want to
one of the many available ruby web frameworks, as others have mentioned.
However it is also possible to start very simply. Here is a “hello
web program in ruby, using the built-in CGI module:
As can be seen from the source code shown on the page, the HTML is
generated dynamically using cgi methods.
Here’s a more real world example of using the CGI module. This is a
program that queries a bunch of online game servers and displays info
about which players are currently connected to which servers:
The source code for that program is here:
Again, we see all the HTML is dynamically generated within the program
itself. This inline approach is often OK for small programs like this,
if one were writing larger web programs, it’s preferable to separate the
HTML from the code. This is usually accomplished with a templating
system, which you’ll be introduced to when you begin exploring the
various ruby web frameworks available.
Hope this helps,