# Ruby?

**URL:** <https://www.ruby-forum.com/t/ruby/132806>\
**Category:** Ruby\
**Created:** [March 24, 2008, 10:13pm UTC](https://www.ruby-forum.com/t/ruby/132806 "2008-03-24T22:13:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kineas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kineas](https://www.ruby-forum.com/u/kineas)\
**Post date:** [March 24, 2008, 10:13pm UTC](https://www.ruby-forum.com/t/ruby/132806/1 "2008-03-24T22:13:54Z")

</div>

I am currently in the planning process of making a website, and I have  
heard that Ruby is good to use, but I am a little confused as to what  
Ruby is. As far as I can tell, it’s code that generates XML (I don’t  
know if I’m right).

I’ve been reading a few tutorials, and have made no sense of them. What  
parts of the website do you use Ruby for? I was presuming HTML was used  
for the structure, and Ruby for certain features.

Can anyone shead a little light on it for me?

---

<div class="post-metadata">

**Author:** ![kineas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kineas](https://www.ruby-forum.com/u/kineas)\
**Post date:** [March 24, 2008, 10:21pm UTC](https://www.ruby-forum.com/t/ruby/132806/2 "2008-03-24T22:21:52Z")

</div>

On Mon, Mar 24, 2008 at 3:13 PM, Gib L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

> **[Ruby on Rails](https://rubyonrails.org)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

> **[nitroproject.org](http://www.nitroproject.org)**
>
> This domain may be for sale!

[http://code.whytheluckystiff.net/camping/](http://code.whytheluckystiff.net/camping/)  
[http://merbivore.com/](http://merbivore.com/)

–  
“Hey brother Christian with your high and mighty errand, Your actions  
speak  
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![kineas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kineas](https://www.ruby-forum.com/u/kineas)\
**Post date:** [March 24, 2008, 10:27pm UTC](https://www.ruby-forum.com/t/ruby/132806/3 "2008-03-24T22:27:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kineas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kineas](https://www.ruby-forum.com/u/kineas)\
**Post date:** [March 24, 2008, 10:25pm UTC](https://www.ruby-forum.com/t/ruby/132806/4 "2008-03-24T22:25:58Z")

</div>

On Mar 24, 2008, at 3:13 PM, Gib L. wrote:

> Can anyone shead a little light on it for me?

Ruby is a general-purpose programming language. It can generate any  
data you’d care to; it’s not specific to web programming as PHP was  
intended, but you can indeed have a process running on the server,  
written in ruby, that serves HTML pages, either static or dynamically  
generated.

---

<div class="post-metadata">

**Author:** ![kineas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kineas](https://www.ruby-forum.com/u/kineas)\
**Post date:** [March 24, 2008, 10:30pm UTC](https://www.ruby-forum.com/t/ruby/132806/5 "2008-03-24T22:30:04Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Mar 24, 2008, at 10:13 PM, Gib L. wrote:

> ## Can anyone shead a little light on it for me?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Ruby is a general purpose programming language. It has no specific  
task, but you can handle  
almost every task with it. No more, no less.

So essentially, you can use Ruby for everything you could use Java/  
Python/PHP for. Ruby has  
some really nice frameworks for web development, Glen already gave you  
the links.

Greetings  
Skade  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkfoHMsACgkQJA/zY0IIRZb0PACfTfRhfUfQr3LmQyhO2wqnu/4g  
tc8AoKuVQXeeobGJoWfbrciOK0pdtFYD  
=ju+J  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![kineas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kineas](https://www.ruby-forum.com/u/kineas)\
**Post date:** [March 24, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/ruby/132806/6 "2008-03-24T23:11:51Z")

</div>

On Mon, Mar 24, 2008 at 5:27 PM, Gib L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 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?

Well, it really depends on what your website is intended to do and  
what Ruby technology/framework you choose.

For example, in something like Rails the site structure emerges from  
the Ruby (controller) classes and the content of the pages would be  
built from HTML with embedded Ruby expressions. (Of course, I have  
glossed over a lot with this simplistic description.) So, for the  
sake of argument, say your website tracks cars and their drivers and  
you are using something Rails-like.

You could create the following Ruby controller classes: CarsController  
and DriversController  
In CarsController, define methods like new and list  
Then you could have URLs like  
/cars/list  
/cars/new  
Each method could have a corresponding HTML snippet (new.rhtml and  
list.rhtml)  
list.rhtml may look like:  
\<% cars.each do |car| %\>

- \<%= car.vin %\>
  
\<% end %\>

> **[Ruby on Rails](https://rubyonrails.org)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

---

<div class="post-metadata">

**Author:** ![kineas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kineas](https://www.ruby-forum.com/u/kineas)\
**Post date:** [March 24, 2008, 11:14pm UTC](https://www.ruby-forum.com/t/ruby/132806/7 "2008-03-24T23:14:13Z")

</div>

Glen H. wrote:

> > ## Can anyone shead a little light on it for me?
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> [www.rubyonrails.org](http://www.rubyonrails.org)  
> [www.nitroproject.org](http://www.nitroproject.org)  
> [http://code.whytheluckystiff.net/camping/](http://code.whytheluckystiff.net/camping/)  
> [http://merbivore.com/](http://merbivore.com/)

Check out this page

[http://ramaze.net/home](http://ramaze.net/home)

near the bottom.

There’s a good list of the 15+ Ruby Web frameworks available.

I’m partial to Ramaze.

To learn more about Ruby the language, see

[www.ruby-lang.org](http://www.ruby-lang.org)

> **[Ruby-Doc.org: Documenting the Ruby Language](https://ruby-doc.org/)**
>
> Fast, searchable Ruby documentation for core and standard libraries. Plus, links to tutorials, guides, books, and related sites.

–  
James B.

[http://www.rubyaz.org](http://www.rubyaz.org) - Hacking in the Desert  
[http://www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys

---

<div class="post-metadata">

**Author:** ![kineas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kineas](https://www.ruby-forum.com/u/kineas)\
**Post date:** [March 25, 2008, 6:08pm UTC](https://www.ruby-forum.com/t/ruby/132806/8 "2008-03-25T18:08:33Z")

</div>

Le 24 mars à 22:27, Gib L. a écrit :

> 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?

Well, you can do everything in Ruby that can be done with a programming  
language, including writing a webserver from scratch…

Now, the common usage is :

- templating (ala PHP / ASP - what you suggest above, a mix and match of  
Ruby code and HTML code),
- database connections (to use with the templates),
- user authentication modules,
- interfacing with mail servers,
- miscellaneous content generation (e.g. generating images or PDF on the  
fly).

A web framework like Rails offers to do all of the above ; some are  
lighter, and some applications can be designed to work with other  
systems (like user authentication modules that could be called directly  
from any kind of web application).

Fred

---

<div class="post-metadata">

**Author:** ![kineas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/d9b06d/32.png) [@kineas](https://www.ruby-forum.com/u/kineas)\
**Post date:** [March 24, 2008, 11:45pm UTC](https://www.ruby-forum.com/t/ruby/132806/9 "2008-03-24T23:45:00Z")

</div>

From: “Gib L.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> 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  
look into  
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  
world”  
web program in ruby, using the built-in CGI module:

[http://billk.tastyspleen.net/cgi-bin/hello-world.cgi](http://billk.tastyspleen.net/cgi-bin/hello-world.cgi)

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:

> **[tastyspleen and friends server status](http://tastyspleen.net/quake/servers/list.cgi)**
>
> Quake 2 forums, servers, downloads, home of the WallFly global Quake 2 server network, and more!

The source code for that program is here:

[http://tastyspleen.net/quake/servers/list.rb](http://tastyspleen.net/quake/servers/list.rb)

Again, we see all the HTML is dynamically generated within the program  
itself. This inline approach is often OK for small programs like this,  
but  
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,

Bill
