Skip to content

Instalacion en Windows

goddamnhippie edited this page Dec 4, 2011 · 1 revision

Instalación de Ruby on Rails en Windows

Windows

Probado en: Windows XP, Windows 7. Si tienes algún problema con la instalación puedes revisar la última sección.

0. Antes que nada

1. Instalar Ruby

La forma más fácil de instalar Ruby sobre Windows es usando RubyInstaller. Es un archivo .exe que contiene el ambiente de ejecución del lenguaje, además de RubyGems.

Descargamos el instalador de Ruby 1.9.2 desde el siguiente enlace:http://rubyforge.org/frs/download.php/75127/rubyinstaller-1.9.2-p290.exe

Una vez descargado, ejecutamos el instalador y seguimos los siguientes pasos:

Paso 1
Paso 2
Paso 3

IMPORTANTE: Asegúrate de marcar la opción 'Add Ruby executables to your PATH'. Ésto actualizará automáticamente la variable PATH de tu sistema.

Abre la terminal dirigiéndote a Inicio -> Ejecutar... y escribe `cmd. Para verificar que Ruby 1.9.2 se encuentre instalado correctamente, escribimos:

$ ruby -v

Esto debería responder así:

ruby 1.9.2p290 (2011-07-09) [i386-mingw32]

Si en lugar de eso, se muestra el mensaje "Command not found", revisa que tu variable PATH incluya el directorio de instalación de Ruby (C:\Ruby192\bin).

Por último, verificamos que la versión 1.7.2 o mayor de RubyGems haya sido instalada.

$ gem -v
1.7.2

2. Instalar DevKit

Descarga el instalador de DevKit desde el siguiente enlace.

Extraemos devkit. (Recomendación: extraer en C:\DevKit)

DevKit

Iniciamos devkit a través de los siguientes comandos:

$ cd C:\DevKit
$ ruby dk.rb init

Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.

Este comando generará el archivo 'config.yml'. Los ambientes de Ruby instalados por RubyInstaller deberán estar listados en ese archivo. Para verificar que se haya cargado nuestra instalación, ejecutamos:

$ ruby dk.rb review

Based upon the settings in the 'config.yml' file generated
from running 'ruby dk.rb init' and any of your customizations,
DevKit functionality will be injected into the following Rubies
when you run 'ruby dk.rb install'.

C:/Ruby192

Si no aparece nuestra instalación de Ruby, debemos agregar la ruta del ambiente Ruby instalado al archivo config.yml de la carpeta en donde instalamos DevKit:

...
- C:/Ruby192
...

Finalmente, instalamos DevKit sobre la instalación de Ruby:

$ ruby dk.rb install

[INFO] Updating convenience notice gem override for 'C:/Ruby192'
[INFO] Installing 'C:/Ruby192/lib/ruby/site_ruby/devkit.rb'

Para verificar la instalación, ejecutamos en el terminal lo siguiente:

$ gem install rdiscount --platform=ruby

...
Temporarily enhancing PATH to include DevKit...
...

Y luego:

$ ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html"

Deberá aparecer el siguiente mensaje:

<p><strong>Hello RubyInstaller</strong></p>

3. Instalar Rails Web Framework

Instalamos Rails con RubyGems:

$ gem install rails

Verificamos la instalación:

$ rails -v

En la terminal se mostrará la versión instalada de Rails:

Rails 3.1.1

4. Creando nuestro primer proyecto en Rails

Es hora de probar nuestra instalación, creemos un proyecto en Rails con el siguiente comando:

$ rails new hello-rails

...
create  vendor/assets/stylesheets
create  vendor/assets/stylesheets/.gitkeep
create  vendor/plugins
create  vendor/plugins/.gitkeep
run  bundle install
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Ejecuta la aplicación:

$ cd hello-rails
$ rails server

Luego, en tu navegador entra a está URL para ver tu sitio activo: http://localhost:3000

Deberías observar lo siguiente:

Hello, Rails

Ahora sí, todo listo para divertirte con Ruby on Rails!

Troubleshooting

  • [Windows7] Error al instalar Rails: error generating ActiveSupport/Inflector.html

Si encuentras el siguiente error:

ERROR:  While generating documentation for activesupport-3.1.1...

MESSAGE:   error generating ActiveSupport/Inflector.html: incompatible
encoding regexp match (UTF-8 regexp with IBM866 string)
(Encoding::CompatibilityError)

... RDOC args: --op
D:/Ruby192/lib/ruby/gems/1.9.1/doc/activesupport-3.1.1/rdoc
lib --title activesupport-3.1.1 Documentation --quiet

Ejecuta el siguiente comando en la terminal chcp 1251 antes de realizar la instalación.