[Nitro] Can nitro be used with eruby?

Fabian Buch fabian at oggu.de
Sun Jun 11 10:11:40 EDT 2006

Am 11.06.2006 um 15:03 schrieb Anne G:
> Installing nitro was not quite as simple as you suggested,
> it seemed to require og, glue, facets, redcloth 3.0.3,
> ruby-breakpoint (0.5) and daemons (0.4.2)

Nitro is tightly coupled with some of these (libraries). Actually Og  
for example is the M part of Nitro's MVC (Model, View, Controller ->  

> Nitro. Your example separates starting webrick from the
> html file structure nitro expects, making it a little
> clearer to me, I will play with Nitro a bit, see if I can
> get an easy implementation of my exercise.

Webrick is just a webserver (http://en.wikipedia.org/wiki/Webserver),  
it's written in ruby and easy to start with, which is the reason for  
Nitro to use it as standard-webserver. It's usually only used in the  
development-phase. Later in deployment you'd usually use a faster/more  
powerful webserver like Apache, Lighttpd or Mongrel.

For Nitro: files in public/ are served statically by the webserver  
(e.g. webrick). The rest is handled by Controller actions.

> since my goal is to understand Web programming (I am working
> on the prerequesite exercises for a 2003 web course posted
> on the web, so real basic stuff right now), I think I should
> use the lightest tool for the task.

Well, Nitro is definitely not the lightest tool, it's a very complex  
and high-level framework. The lightest would maybe be mod_ruby, eruby  
or PHP (if you're not limited to the Ruby programming language).

> Templates vs Framework
> All of the frameworks offer a way to map a URL to a template
> file. In addition to simple mappings similar to the handling
> of static documents, some offer ways to intercept all
> requests within a certain directory for pre-processing, or
> create an object inheritance scheme out of the directory
> structure of a site.
> http://perl.apache.org/docs/tutorials/tmpl/comparison/ 
> comparison.html#Application_Frameworks_vs__Just_Templates

This is a very limited view. You should probably read a little bit  
more: http://en.wikipedia.org/wiki/Web_application_framework and all  
web frameworks work a little bit different:  

> As I understand it, eruby is a pre-processor. When you try
> to access an rhtml file, eruby is called first, runs, is
> replaced by the result of the computation, and then the
> browser presents the resulting html file.
> A framework is just a bunch of code. Since you say Rails is
> based on erb, I should be able to recreate Rails like
> behavior out of just ruby and erb.

Well, basically yes, but it's not just "a bunch of code", it's a lot of  
code and a lot of ideas. It's nothing you could achieve in a few  
months. The templating in Rails is only a small part of Rails and not  
only erb either.

> When the browser receives a pgm.rhtml request, it looks for
> a pgm.rhtml file in the given directory.

Depends on how your files are served by the webserver or your  
framework, which again can be like you said above or even totally  
different (it's more complex in most web application frameworks).

> With the frameworks rails and nitro, somehow running nitro
> links up a directory to an address localhost:9999, and then
> any address down stream from that adress is captured by the
> program and redirected by it.

Not necessarily. I'm not so familiar with Rails, but for Nitro: some  
files (like in public/) are served directly by the webserver, others  
aren't and might be processed or created by Controllers.

> Right now I can't see how to get that kind of basic behavior
> with eruby, since there must be an exact match one to one
> between an url and a file. Yet you tell me that rails does
> it with erb. and erb and eruby are very similar. What is the
> key idea I am missing?

The MVC paradigm probably! For Rails or Nitro you have to get an idea  
of what this mean. Read some more of the links I provided above.
I'm not sure whether you need this as web application development  
beginner though and whether eruby or php might not be sufficient for  
you. That's something you gotta figure out. As a beginner it's  
definitely easier to start with non-MVC in PHP or eruby (if it has to  
be ruby).


PS: btw. before you ask, MVC (http://ootips.org/mvc-pattern.html) is  
not only for web applications, it's also used by many other  
applications, especially GUI applications and only recently found it's  
way into the web.

More information about the Nitro-general mailing list