How to Setup Rails Development Environment?

Couple of months back I had a situation, which concerned about installing Ruby and Rails on my system. After reading through many blogs and posts related with installation, at last I found RVM (Ruby Version Manager) as the best option among all. Most importantly I didn’t need to Google all the errors, which pops up while installing them using other methods. With RVM comes lots of flexibility and installation is pretty easier.

Note: I have tested these installation steps on ubuntu versions.

Normas

 This beginner’s guide will set up with Ruby 1.9.3, RVM and Rails 3.1.3 and is specifically written for a development environment on Ubuntu 10.10, but will probably work on many other operating systems, including older/newer versions of Ubuntu and Debian.

  • Si uno está buscando una manera de configurar esto en un servidor de producción, entonces se recomienda el uso del “script Railsready” que instala todos los paquetes necesarios para Ruby 1.9.3p0 y luego esa versión del propio Ruby, Bundler y Rails. Luego, le corresponde al usuario instalar Apache o nginx para que su aplicación esté en línea.
  • Under no circumstance should one install Ruby, Rubygems or any Ruby related packages from apt-get. This system is outdated and leads to major headaches. Avoid it for Ruby-related packages.
Installation Procedure

1. First of all, update the system, so that all the latest resources are updated to install latest packages.

   Abrir terminal (alt+ctrl+t).

   In terminal type:- sudo apt-obtener actualización

2. Next, we’re going to install Git (a version control system) and curl which are both required to install and use RVM, and build essential which is required to compile Ruby versions, amongst other compilable things. To install these three packages we use this command:

    sudo apt-get install build-essential git-core curl

3. Installing RVM (Ruby Version Manager)

  RVM is a Ruby Version Manager created by Wayne E. Seguin and is extremely helpful for installing and managing many different versions of Ruby all at once. Sometimes you could be working on a project that requires an older (1.8.7) version of Ruby but also need a new version (1.9.3) for one of your newer projects. This is a problem that RVM solves beautifully.

  Otra situación podría ser que quieras tener diferentes conjuntos de gemas en la misma versión de Ruby pero no quieras tener que lidiar con Gem Conflict Hell. RVM tiene conjuntos de gemas para esto. Esta es una característica que no tendrías si usaras el Ruby empaquetado.

=> With git-core and curl installed we’ll be able to install RVM with this command: => Run this command in terminal bash < <(curl -s http://rvm.beginrescueend.com/install/rvm) =>The beautiful part of this is that it installs Ruby to our home directory, providing a sandboxed environment just for us.

=>Once that is done add following line to your ~/.bashrc file. => echo ‘[[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm”‘ >> ~/.bashrc //.bashrc file is responsible for setting up the bash session

=>Then we’ll need to reload ~/.bashrc file,which can be done using this small command. => . ~/.bashrc => After using above command,if error comes i.e rvm(commadn not found) etc…Then simply close this terminal and start again(Beleive me,few times such things do work!!!)

=>Next we have to see what are the things required by RVM to install Ruby on Rails. Just use:- => rvm requirements //this will show all the packages required to be installed before,few of which we may have already installed.

=>To install all the required packages mentioned by rvm requirements,just run following command:- =>sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core //please note these all should be contained in single line, otherwise zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev //few packages may not get installed. libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

  1. Installing Ruby and Rails–>Installing Ruby4.1 With RVM and packages installed,we can install ruby using :- => rvm install 1.9.3 //this will install ruby with 1.9.3 version and it takes a little time to get installed. Be patient.4.2 With RVM installed, we can use that particular version to be used:- => rvm use 1.9.3 //now the ruby 1.9.3 will be used as a ruby version4.3 To check the version of the ruby version installed:- => ruby -v //check the current version being used4.4 To make a particular version to be used as default,we can use:- => rvm –default use 1.9.3=> Installing Rails4.5 As we have installed ruby in our home directory, we dont need to use sudo command for rails installation. Simply type following command:-
    => gem install rails -v 3.0.9 //This will install 3.0.9 version.Any suitable version can be downloaded by just mentioning the version here.  //También instalará la gema Rails y las otras 22 gemas de las que dependen ella y sus dependencias, incluido Bundler.

5.Well, Thats it !!  Enjoy coding !

Póngase en contacto con nosotros. Ahorrar

Suscríbete para recibir las últimas actualizaciones

Artículos Relacionados

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

es_ESSpanish