What I learned from GSoC?

Google Summer of Code was a wonderful experience for me, I’ll never forget it. I finished my project and that makes me feel great. Getting opinions and feedback from the Open Source community was really special. In general, this is what I learned:


Improved my communication skills: Doing a project that involves other people means that you have to be clear in your words, be brief but efficient, and most important, make people understand what you are trying to say.


I wrote a lot in English. (My project, IRC meetings, asking in the list, answering questions, etc). Although, English is not my first language I enjoyed having to be clear with my mentor, the OSVDB (Open Sourced Vulnerability Database) developers and the Google group of summer of coders.


Ruby and Ruby on Rails: This Ruby user’s guide helped me a lot. I haven’t finished it, but I learned a lot about this great language (regular expressions, strings, arrays, iterators, control structures, OOP, classes, methods). And I also do a lot of programing with the ruby on rails framework. I learned how to manage and modified some plugins.

Actually, working with views is not my favorite part of a project. However, CSS work at the end of the project was really fun. What CSS makes is impressive.

Solr: I never ever have worked with a search server. Solr is just amazing – Fulltext search capabilities. I learned how to integrate Solr and the act_as_solr plugin to my Rails application.

Subversion: I learned how to work with this collaboration tool which I consider makes you more productive. However, I had to deal with so many error messages. I need to learn more commands apart from the common ones.

Vulnerability and Patch concepts.

I believe that being an expert in these fields takes his time. I never did a security system and didn’t work with a security team before. But I learned key concepts related to patches and vulnerabilities that helped me a lot to write the code. For example:

  • Vulns classification: Location, Attack Type , Impact, Solution, Exploits.
  • Vulns technical description and how to test a vulnerability.
  • Patch severity: Critical, Severe,important, Minor, Pointless.
  • Security Products: Nikto, Snort and Nessus.
  • What CVE means.
  • How to associate a vuln-patch with a Vendor/Product/Version.

Many lessons learned in these months let me think what I did wrong and what I did well. I feel that  I’m not always as productive as I might like to, my effort changes with the tasks I’m doing.

Once I read some Linus interview in which he said that if you are completely present in a situation and totally focused on something then that something *becomes* interesting, whatever it may be.

So, I think that making your job interesting and fun and get really focused on the problem are the keys to your project success.

Thanks for your visit to the blog. You can follow me on Twitter:

¡Happy Hacking!

Rails 2.2 will be thread safe

Reading the rubyonrails blog I read that Rails 2.2 will be thread safe and that this hard work comes from a Google Summer of Coder. Josh Peek who will join the rails core.

This is a great advance for the framework, because many people were looking for merb for this rails weak, but this improvement will attract new developers to join the rails community.

Congratulations Josh.
Thanks for your visit to the blog. You can follow me on Twitter:


Rdoc – Generating documentation for Ruby and Rails

Rdoc is a program for creating documentation for ruby source code. Rdoc generates HTML documentation, using syntactic information from the source and text in comment blocks.

You can check documentation about ruby libraries if you have ruby property installed by running the ri command. For example, if we want to know what the capitalize method does, just type in your terminal:

ri String.capitalize

str.capitalize    => new_str
Returns a copy of str with the first character converted to
uppercase and the remainder to lowercase
"hello".capitalize  #=> "Hello"
"HELLO".capitalize  #=> "Hello"
"123ABC".capitalize  #=> "123abc"

Rdoc is very useful to look for information about programs, methods and examples.

If you want to see the rails api documentation type in your terminal: gem server and then go to your browser at the url http://localhost:8808

You will get an HTML page “RubyGems Documentation Index” with a summary of all ruby gems installed on your system.

Click on the gem you want to see the documentation and you will see an HTML page with 3 columns: (Files, Classes, Methods) and everything documented in detail.

If you installed rails with rubygems you can access the rails API. Also the rake app:doc command creates the HTML documentation for your Rails project and stores this documentation in the doc/app directory.

Run the file  doc/app/index.html and you will see of the documentation of your rails project.
Thanks for your visit to the blog. You can follow me on Twitter:

Query analyzer for Rails

I found an interesting and very useful plugin for rails called Query analyzer that allows us check for tables not optimized in our database. It really helps a lot to optimize tables and queries and put indexes on our conditions columns and primary/foreign keys. Sometimes, we forget to do things so simple like this.  Here is a great explanation of what the plugin does.

How to use it? Just install the plugin with:

script/plugin install http://svn.nfectio.us/plugins/query_analyzer

Then check your logs. You can see your console as well. Once you have the plugin installed you will see all queries your application does and how they are currently managed.

For example:

I have a table called form_help_divs. It is a table to show some messages in forms around my application. I usually make a call to the database to get a form_help_div record. The query generated is like this:

SELECT * FROM `form_help_divs` WHERE (`form_help_divs`.`name` = 'patch_vuln') LIMIT 1

So in theory. The query should check for only one row, but that is not true because the name column doesn’t have an index. And how I realized that?. I just checked my log and saw this:

Analyzing FormHelpDiv Load

select_type | key_len | type | Extra       | id | possible_keys | rows | table          | ref | key
SIMPLE      |         | ALL  | Using where | 1  |               | 33   | form_help_divs |     |

As you see the query is looking for all records (in this case 33) in the database searching for the name ‘patch_vuln’. That is not good guys. Let us optimize our queries by adding and index to that table. We can add it by hand in our mysql interface, but is better to create migrations.

class AddFormHelpDivIndexes < ActiveRecord::Migration
    def self.up
        add_index :form_help_divs, :name

    def self.down
        remove_index :form_help_divs, :name

Type rake db:migrate in your console and your migration will be executed.Now run your application again and you will see the difference in your logs and console. This is the result:

FormHelpDiv Load (0.001585)   SELECT * FROM `form_help_divs` WHERE (`form_help_divs`.`name` = 'patch_vuln') LIMIT 1

Analyzing FormHelpDiv Load

select_type | key_len | type | Extra     | id | possible_keys | rows |table  | ref   | key
SIMPLE   |768|ref|Using where|1|name,index_form_help_divs_on_name|1|form_help_divs | const | name

¡What a big difference!. Now the query is looking just for one row in the database and that will increase the query speed significantly.

There are other ways to make our applications running faster with rails. Adding indexes is one of those ways and let us gain a lot of optimization specially if we are working with big applications and tables with so many records.
Thanks for your visit to the blog. You can follow me on Twitter:


Rake is a Ruby program that builds other Ruby programs.  Each time you execute rake, it knows how to build those programs by reading a file called Rakefile which has a set of tasks.  Those tasks allows us to do some project needs in a very easy and efficient way.

When you generate a rails project you automatically get a Rakefile and it is located in the root of your project.

You can see all rake tasks and their descriptions by running a simple command in your main directory:

rake –tasks

And this should be shown:

 rake backgroundrb:remove # Remove backgroundrb from your rails ...
 rake backgroundrb:restart # Restart backgroundrb server (default...
 rake backgroundrb:setup # Setup backgroundrb in your rails app...
 rake backgroundrb:start # Start backgroundrb server (default v...
 rake backgroundrb:stop # Stop backgroundrb server (default va...
 rake db:abort_if_pending_migrations # Raises an error if there are pending...
 rake db:charset # Retrieves the charset for the curren...
 rake db:collation # Retrieves the collation for the curr...
 rake db:create # Create the database defined in confi...
 rake db:create:all # Create all the local databases defin...
 rake db:drop # Drops the database for the current R...
 rake db:drop:all # Drops all the local databases define...
 rake db:fixtures:identify # Search for a fixture given a LABEL o...
 rake db:fixtures:load # Load fixtures into the current envir...
 rake db:migrate # Migrate the database through scripts...
 rake db:migrate:redo # Rollbacks the database one migration...
 rake db:migrate:reset # Resets your database using your migr...
 rake db:reset # Drops and recreates the database fro...
 rake db:rollback # Rolls the schema back to the previou...
 rake db:schema:dump # Create a db/schema.rb file that can ...
 rake db:schema:load # Load a schema.rb file into the database
 rake db:sessions:clear # Clear the sessions table
 rake db:sessions:create # Creates a sessions migration for use...
 rake db:structure:dump # Dump the database structure to a SQL...
 rake db:test:clone # Recreate the test database from the ...
 rake db:test:clone_structure # Recreate the test databases from the...
 rake db:test:prepare # Prepare the test database and load t...
 rake db:test:purge # Empty the test database
 rake db:version # Retrieves the current schema version...
 rake doc:app # Build the app HTML Files
 rake doc:clobber_app # Remove rdoc products
 rake doc:clobber_plugins # Remove plugin documentation
 rake doc:clobber_rails # Remove rdoc products
 rake doc:plugins # Generate documentation for all insta...
 rake doc:rails # Build the rails HTML Files
 rake doc:reapp # Force a rebuild of the RDOC files
 rake doc:rerails # Force a rebuild of the RDOC files
 rake log:clear # Truncates all *.log files in log/ to...
 rake notes # Enumerate all annotations
 rake notes:fixme # Enumerate all FIXME annotations
 rake notes:optimize # Enumerate all OPTIMIZE annotations
 rake notes:todo # Enumerate all TODO annotations
 rake rails:freeze:edge # Lock to latest Edge Rails or a speci...
 rake rails:freeze:gems # Lock this application to the current...
 rake rails:unfreeze # Unlock this application from freeze ...
 rake rails:update # Update both configs, scripts and pub...
 rake rails:update:configs # Update config/boot.rb from your curr...
 rake rails:update:javascripts # Update your javascripts from your cu...
 rake rails:update:scripts # Add new scripts to the application s...
 rake remove_simple_captcha_files # Remove unuseful captcha images and s...
 rake routes # Print out all defined routes in matc...
 rake secret # Generate a crytographically secure s...
 rake solr:destroy_index # Remove Solr index
 rake solr:start # Starts Solr.
 rake solr:stop # Stops Solr.
 rake stats # Report code statistics (KLOCs, etc) ...
 rake test # Test all units and functionals
 rake test:functionals # Run tests for functionalsdb:test:pre...
 rake test:integration # Run tests for integrationdb:test:pre...
 rake test:plugins # Run tests for pluginsenvironment / R...
 rake test:recent # Run tests for recentdb:test:prepare ...
 rake test:uncommitted # Run tests for uncommitteddb:test:pre...
 rake test:units # Run tests for unitsdb:test:prepare /...
 rake tmp:cache:clear # Clears all files and directories in ...
 rake tmp:clear # Clear session, cache, and socket fil...
 rake tmp:create # Creates tmp directories for sessions...
 rake tmp:pids:clear # Clears all files in tmp/pids
 rake tmp:sessions:clear # Clears all files in tmp/sessions
 rake tmp:sockets:clear # Clears all files in tmp/sockets
 rake uml:schema # Generate an XMI db/schema.xml file d...

Those rake tasks will be used many times when developing your rails application.
For example, there is an interesting task rake stats which generates detailed statistics about your application code and provides a dashboard of information.  This is what I get:

| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
| Controllers          |  6080 |  5241 |      54 |     369 |   6 |    12 |
| Helpers              |   552 |   501 |       0 |      25 |   0 |    18 |
| Models               |  3855 |  3274 |     157 |     326 |   2 |     8 |
| Libraries            |  3068 |  2806 |      18 |      71 |   3 |    37 |
| APIs                 |     9 |     9 |       1 |       0 |   0 |     0 |
| Components           |     0 |     0 |       0 |       0 |   0 |     0 |
| Integration tests    |     0 |     0 |       0 |       0 |   0 |     0 |
| Functional tests     |  1261 |   942 |      97 |     200 |   2 |     2 |
| Unit tests           |  1246 |   884 |     117 |     129 |   1 |     4 |
| Total                | 16071 | 13657 |     444 |    1120 |   2 |    10 |
Code LOC: 11831     Test LOC: 1826     Code to Test Ratio: 1:0.2

There are many other rake commands very useful for rails development.

Thanks for your visit to the blog. You can follow me on Twitter:

Hpricot installation problem

Hpricot is a fast,  flexible HTML parser written in C. Hpricot can be handy for reading broken XML files,  since many of the same techniques can be used. If a quote is missing Hpricot will try to figure it out.

I was really having problems to install hpricot,  the newest version is 0.6.  Whenever I executed:

$ sudo gem install hpricot
Select which gem to install for your platform (arm-linux)
1. hpricot 0.6 (mswin32)
2. hpricot 0.6 (jruby)
3. hpricot 0.6 (ruby)
4. hpricot 0.5 (ruby)
5. hpricot 0.5 (mswin32)
6. Skip this gem
7. Cancel installation
> 3

I received the following message:

Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

I Typed this to see what is going on:

ruby extconf.rb install hpricot

and the error continue

extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1

Gem files will remain installed in /var/lib/gems/1.8/gems/hpricot-0.6 for inspection. Results logged to /var/lib/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/gem_make.out

Googling for a while,  I found a good solution in the hpricot project wiki.  The main problem is that I had ruby 1.8 and 1.9 installed. Ruby 1.8.5 was the version I was using, but I didn’t have development libraries installed.  So, gem couldn’t install correctly hpricot.

You can check your version for ruby, rails, gem and everything else by typing -m after the program name.

$ ruby -v
ruby 1.8.5 (2006-08-25) [i486-linux]
$ gem -v

The solution: There is a file we need,  called mkmf.rb. It has connection with ruby libraries,  so let’s search it.

$ auto-apt search mkmf.rb
usr/lib/ruby/1.9/mkmf.rb        devel/ruby1.9-dev

As you can see, we don't have it in ruby1.8 directory, so let us install ruby1.8 development libraries.

$ sudo apt-get install ruby1.8-dev

and now, we have the mkmf.rb in ruby1.8

$ auto-apt search mkmf.rb
usr/lib/ruby/1.9/mkmf.rb        devel/ruby1.9-dev
usr/lib/ruby/1.8/mkmf.rb        devel/ruby1.8-dev

There is no documentation in the wiki,  but I assume that you have to install another gem called mechanize which is  an hpricot  dependency.

$ sudo gem install mechanize
Install required dependency hpricot? [Yn]
Select which gem to install for your platform (arm-linux)
1. hpricot 0.6 (mswin32)
2. hpricot 0.6 (jruby)
3. hpricot 0.6 (ruby)
4. hpricot 0.6 (jruby)
5. hpricot 0.6 (ruby)
6. hpricot 0.6 (mswin32)
7. Skip this gem
8. Cancel installation
> 3
Building native extensions.  This could take a while...
Successfully installed mechanize-0.6.9
Successfully installed hpricot-0.6
Installing ri documentation for mechanize-0.6.9...
Installing ri documentation for hpricot-0.6...
Installing RDoc documentation for mechanize-0.6.9...
Installing RDoc documentation for hpricot-0.6...

Finally, you will get hpricot successfully installed and now you can use this great gem.

Thanks for your visit to the blog. You can follow me on Twitter:


Rails has a great feature called migrations which allow the developer to have control over the database schema by using ruby code and avoiding use the conventional SQL language. But, more important is that the developer can apply certain changes to move a database from one state to another,  add-remove columns, indexes,  tables etc.  By using migrations you can get different versions of your database structure.

How it works? Migrations are files found in the db/migrate directory and have a sequence number in the filename.

For example, each time you want to add a migration you can generate it with:

./script/generate migration CreateCompanies

exists  db/migrate
create  db/migrate/001_create_companies.rb
Loaded suite ./script/generate
Finished in 0.002254 seconds.
0 tests, 0 assertions, 0 failures, 0 errors

If you see the file, this was generated for you:

class CreateCompanies < ActiveRecord::Migration
    def self.up


    def self.down


and now you can modify it to create a table, the syntax is the folowing:

class CreateCompanies < ActiveRecord::Migration
    def self.up
        create_table :companies do |t|
            t.string    :name
            t.text      :description
            t.datetime  :created_on

    def self.down
        drop_table :companies

I think the code is explained implicity.  It’s similar to an sql creation,  but this time you have to add the datatype first and then the column name.

Possible Column types:
:string, :text, :integer, :float, :datetime, :timestamp, :time, :date, :binary, :boolean

Column details:
:limit: Maximum long characters in the column (for types :string, :text, :binary or :integer)
:default: Specify the default value of the column.
:null: Enable or disable the value NULL in a column.

To get this table created, just you have to run the command: rake db:migrate and the companies table will be created.

Imagine you want to create another table users, generate it with:

./script/generate migration CreateUsers

exists  db/migrate
create  db/migrate/002_create_users.rb
Loaded suite ./script/generate
Finished in 0.002254 seconds.
0 tests, 0 assertions, 0 failures, 0 errors

Modify the file 002_create_users.rb

class CreateUsers < ActiveRecord::Migration
    def self.up
        create_table :users do |t|
            t.string   :login
            t.string   :email
            t.string   :password,   :limit => 20
            t.datetime :created_at
            t.datetime :updated_at
            t.integer  :status
            t.datetime :last_login

    def self.down
        drop_table :users

and if you run rake again db:migrate table users will be created in your database. You are probably wondering how rails knows next migration should be named 002 and when running rake db:migrate which migration has to be executed.

Whenever doing these operations rails checks in your database a table called schema_info, which has the latest version of your database schema.  So, that way rails knows which migration number to apply or generate.

Try to run again rake db:migrate and you will receive an error message

Mysql::Error: Table ‘users’ already exists:

telling you that table users already exists.  This is because this migration was already executed and in your schema_info table the version is 2 (the same as the number of your migration). Now you can realize what the pattern is.  Also you can execute an specific migration by running:

rake db:migrate version= version_number

version_number is the version you want to be executed.

When developing your rails application you will see that migrations are very useful because you are database-independent, can change to one version or another and undo changes easily.
Thanks for your visit to the blog. You can follow me on Twitter:

La revolución del desarrollo Web: Ruby on Rails

Desde la aparición de Internet, hemos sido testigos de diversos sitios web, variedad de aplicaciones y tecnologías que evolucionan constantemente.Actualmente se está viviendo una revolución en el mundo Web denominada: Web 2.0. Podríamos referirnos a Web 2.0 como el desarrollo de aplicaciones modernas, super dinámicas, orientadas a la interacción y creación de redes sociales que fomenten la participación de los usuarios.
La Web 2.0 hace uso de técnologías y técnicas como AJAX, XML, SEO,  CSS avanzado, Sindicación de contenidos, patrones de diseño, estándares Web, folksonomía, usabilidad, enfoque en la simplicidad etc.  Muchas de estas aplicaciones han sido y están siendo desarrolladas con la plataforma Web Ruby on Rails, y al parecer, elegir este entorno de desarrollo, es una gran decisión.

Si hay alguien que está haciendo ruido, captando la atención de varios programadores, usuarios, empresas de software y ganando mucho prestigio en la Web,  es sin duda Ruby on Rails. Y seguramente nos preguntamos:

¿Qué es Ruby?, ¿Qué es Rails?, ¿Qué es Ruby on Rails?, ¿Porqué está haciendo tanta ruido y ganando mucha popularidad?, ¿Porqué sus aplicaciones son robustas, eficientes, y rápidas, creadas con un código sencillo y elegante? ¿Porqué dicen que incrementa la productividad,  creatividad e innovación en los programadores? ¿Quién lo utiliza? ¿Cómo inicio?.

Es hora de empezar…

¿Qué es Ruby?

Es un lenguaje de programación dinámico totalmente orientado a objetos, multiplataforma y Open Source, creado en 1995 por Yukihiro Matsumoto, en Japón.  Dentro de sus fortalezas, el lenguaje Ruby permite una gran productividad del programador gracias a un enfoque hacia la simplicidad, menos código, menos errores, mayor facilidad de mantenimiento, sin necesidad de compilación. El resultado: el tiempo se dedica a construir aplicaciones potentes, de una manera eficiente, rápida y sencilla.

Ha combinado muchas de las características positivas de Perl, PHP, Java, C, Smalltak, Lisp. haciendo un lenguaje potentísimo para el desarrollo de aplicaciones.

Es considerado un lenguaje muy intuitivo casi a un nivel de lenguaje humano, que de una forma se asemeje al lenguaje natural, de esta forma hace que la experiencia de programación sea más divertida.

¿Qué es Rails?

Rails es un framework,  es decir, un conjunto de programas,  librerías que ayudan a desarrollar y unir los diferentes componentes de un proyecto de software.  Rails también es Open Source,  multiplataforma, distribuido bajo la licencia del MIT. Fue desarrollado integramente con el lenguaje Ruby por el danés David Heinemeier Hansson y liberado al público por primera vez en Julio de 2004.

Soporte de Rails

Plataformas : GNU/Linux, Unix, FreeBSD, Mac OS X, Windows.
Bases de Datos : PostGreSQL, MySQL, Oracle, SQL Server, SQLite, IBM DB2.
Servidores Web : Webrick (Servidor integrado con Rails), Apache, Lighttpd.

De la combinación del lenguaje Ruby más el framework Rails, surge la plataforma para desarrollo Web.

Ruby on rails, también conocida como RoR

La filosofía de Ruby on Rails, se basa en dos principios fundamentales: “No te repitas” y “Convención sobre configuración”.

No te repitas se refiere a que las definiciones deberían hacerse una sola vez, pues los componentes están integrados de manera que no hace falta establecer puentes entre ellos. Cada pieza de conocimiento en un sistema, deberá ser expresada en un sólo lugar.  Este principio se basa en escribir menos lineas de código para implementar la aplicación.  Si el código es pequeño quiere decir que el desarrollo es más rápido y con menos errores, lo que hará que el código sea fácil de entender, mantener y mejorar.

Convención sobre configuración significa que el programador sólo necesita definir aquella configuración que no es convencional. En lugar de archivos de configuración, utilizamos una serie de convenciones simples que permiten averiguarlo todo.

Arquitectura: Patrón MVC
Ror facilita el diseño y desarrollo de aplicaciones web separando automáticamente en 3 capas todos los componentes de la aplicación (Modelo, Vista y Controlador).

  • Modelo es todo acceso a base de datos, y las funciones que contienen la “lógica de negocio”.
  • La vista se encarga de mostrar la información al usuario final:  HTML, XML.
  • El controlador une la vista con el modelo, contiene toda la lógica de programación.  Almacena las funciones que toman los valores de un formulario, delega consultas de base de datos al modelo y produce valores que invocarán a la vista adecuada.

En conclusión con Ror nos centramos en lo que verdaderamente importa: la funcionalidad de nuestra aplicación y podemos crear aplicaciones más complejas y de funcionamiento más “suave” con muchísimo menos esfuerzo. Algunas ejemplos de grandes aplicaciones hechas con RoR son:  Basecamp, La Coctelera,  Odeo,  43things,  Shopify,  Fluxiom,  Typo,  Bigcartel,  WriteBoard,  SoapBX,  Campfire,  BackPack, entre otras.

Instalación de Ruby on Rails en Linux:

1.- Descargamos la última versión de Ruby desde http://www.ruby-lang.org/en/downloads   (Actualmente la 1.8.6 es la versión estable).

2.- Descomprimimos el archivo:
[ruby@localhost ~]$ tar xvzf ruby-1.8.6.tar.gz

3.- Ingresamos al directorio de ruby y compilamos:
[ruby@localhost ~]$ cd ruby-1.8.6
[ruby@localhost ruby-1.8.6]$ ./ configure & make && make install

En Debian y sus derivadas. Actualizamos nuestro listado de paquetes disponibles.
[ruby@localhost ~]$ sudo apt-get update
Instalamos el lenguaje ruby, el archivo con la documentación de ruby y el modulo de ruby para apache:
[ruby@localhost ~]$ sudo apt-get install ruby rdoc libapache-mod-ruby

4-Luego descargamos el gestor de paquetes Rubygems desde http://rubyforge.org/frs/?group_id=126 (Actualmente la última versión es la 0.9.3).

5.- Lo descomprimimos con:
[ruby@localhost ~]$ tar xvfz rubygems-0.9.3

6.-Ingresamos al directorio de rubygems y lo instamos con :
[ruby@localhost ~]$ cd rubygems-0.9.3
[ruby@localhost rubygems-0.8.11]$ ruby setup.rb

7.-Ahora pasamos a instalar Rails con el comando gem (nos instalará la última versión):
[ruby@localhost rubygems-0.8.11]$ gem install rails –remote –include-dependencies

Este parámetro –remote –include-dependencies significa que debemos de instalar algunas dependencias con las que debe contar rails. En total son 6 paquetes:


Listo, ya tenemos instalado Ruby, Rails y podemos empezar a desarrollar.

8. Ahora crearemos la estructura de nuestra primera aplicacion rails.  Ejecutamos el comando rails con el nombre de nuestra aplicación.

[ruby@localhost]$ rails nuestra_aplicacion
El comando rails creará un directorio con el nombre de nuestro proyecto y dentro de el armará una estructura, una serie de subdirectorios con los cuales iniciaremos nuestro trabajo con Ruby on Rails.

 create app/controllers
 create app/helpers
 create app/models
 create app/views/layouts
 create config/environments
 create components
 create db
 create doc
 create lib
 create lib/tasks
 create log
 create public/images
 create public/javascripts
 create public/stylesheets
 create script/performance
 create script/process
 create test/fixtures
 create test/functional

9.- Ahora para ver nuestro proyecto en marcha nos ubicamos dentro del directorio nuestra_aplicacion y ejecutamos:

[ruby@localhost]$ cd nuestra_aplicacion
[ruby@localhost nuestra_aplicacion]$ ruby script/server

10.- En esa consola obtendremos una salida como esta:

=> Booting WEBrick...
 => Rails application started on
 => Ctrl-C to shutdown server; call with --help for options
 [2006-01-23 16:45:54] INFO WEBrick 1.3.1
 [2006-01-23 16:45:54] INFO ruby 1.8.4 (2005-12-24) [i386-linux]
 [2006-01-23 16:45:54] INFO WEBrick::HTTPServer#start: pid=7627 port=3000

11.- Nuestro servidor atenderá el puerto 3000.  Si usamos nuestro navegador y apuntamos a la dirección http://localhost:3000  nos saldrá un mensaje de bienvenida:


Si ejecutamos con ctrl + c, en el terminal o consola donde se está ejecutando nuestra aplicación detendremos el servidor Webrick y por ende la aplicación. Para facilitar el desarrollo podemos instalar plugins para distintos editores como Gedit, Jedit, Komodo Edit, la librería FastCGI para Ruby y un IDE como RadRails, aunque existen otros.
Podemos probar ruby desde nuestra consola, instalando el intérprete irb.

Estadísticas que publica en la edición de Febrero de 2006 la revista de IEEE Computer Society.

  • En enero de 2006 eran 230 000 el número de copias descargadas de Ruby on Rails.
  • En la actualidad el 5% de los programadores lo usan de forma regular. Su principal fortaleza es la rapidez para el desarrollo de aplicaciones web: “Un programador de Rails puede hacer el mismo trabajo que un equipo de Java porque las cosas son simples, rápidas, pero muy potentes” (Curt Hibbs).
  • “En un pequeño desarrollo para una startup el código fue la cuarta parte, y el tiempo de configuración el 10% del que hubiéramos empleado con Java” (Bruce Tate).
  • Según Tiobe.com, Consultora dedicada al seguimiento de la calidad de software y la popularidad de los lenguajes de programación. De enero de 2006 a enero de 2007, Ruby escala 10 posiciones. Del puesto número 21, ahora se encuentra en el puesto 10.
  • El prestigioso sitio para de diseño y programación para la web SitePoint publicó los resultados de una reciente encuesta a 5000 desarrolladores logrando “la más completa encuesta dedicada a webdevelopers”.
  • Además de los números que era previsible encontrar, como que el 68% de ellos programa en PHP (con el 33% haciéndolo solamente en ese lenguaje), también hay otros datos resaltantes:
  • 24% de los desarrolladores (o sea, aproximadamente 1200) migrarán a programar en Ruby on Rails en los próximos 12 meses.

“En todos lados.  Desde la programación de computadoras Palm hasta la programación de supercomputadoras, desde programación embedida hasta bioinformáica, la programación deberá SIEMPRE de ser divertida. Ruby cumple con esta mención”. David Heinemeier Hansson.

“Ruby on Rails es increíble. Usarlo es como estar viendo una película de kung-fu, donde una docena de frameworks malvados se preparan para golpear al nuevo y pequeño recién llegado, pero al final terminan derrotados por una gran variedad de imaginativas formas”.  Nathan Torkington de O’Reilly.

“Cada vez que hago la pregunta a un programador si es significativamente más productivo con Ruby que con Java/C#/PHP, recibo de respuesta un contundente sí. Esto es suficiente para mí, para empezar diciendo que tú deberías probar Ruby,  lo cual porsupuesto,  hará que te hagas la pregunta a ti mismo y respondas si lo crees conveniente”.  Martin Fowler.

“Que Ruby sea riesgoso, es una opinión común, y por buena razón.  Los nuevos lenguajes son intrínsecamente riesgosos. Pero Ruby on Rails está más cercano a ser el principal, ese riesgo disminuirá, porque tendrás acceso a un sistema con un crecimiento cada vez mayor de programadores,  de componentes  (llamados gems o los plug-ins),  de libros,  y de nuevos modelos de negocio”.  Bruce Tate.

Gracias por tu visita al blog.  Puedes seguirme en Twitter haciendo click en el siguiente enlace: