0

my question is straight, Please give me answers with some details of the tools that I use. I have done some research and I am not getting a straight solution.

I am trying to run a rails application that is using rails version 4.0.4 and ruby version 2.1.1. How can I set up the environment in my windows laptop?

ben
  • 6,000
  • 5
  • 35
  • 42

1 Answers1

1

Maybe you should create an Ubuntu Virtual Machine using Vagrant to run your rails app.

First of all, download VirtualBox and Vagrant.

Then change to a directory where you’ll build your project C:\projects\starting_rails for example and from that directory run:

$ vagrant init hashicorp/precise32
$ vagrant up
$ vagrant ssh

Those commands will create an Ubuntu virtual machine, set it up and then you will be able to login through ssh.

Inside the vm, you'll need to config everthing in order to run you rails app.

Install the PostgreSQL

# set that default locale before install postgres
$ sudo /usr/sbin/update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
$ sudo apt-get install postgresql libpq-dev

Once installed, create the database instance. Within the SSH session

$ sudo mkdir -p /usr/local/pgsql/data
$ sudo chown postgres:postgres /usr/local/pgsql/data
$ sudo su postgres
$ /usr/lib/postgresql/9.1/bin/initdb -D /usr/local/pgsql/data
$ createuser vagrant

Respond "Y" to Shall the new role be a superuser? Then you can 'exit' the su subshell.

Add privilege for vagrant to create db.

$ psql postgres psql
$ ALTER ROLE vagrant CREATEDB;
# exit with \q
$ \q

Then it is time to install RVM a ruby version manager.

$ sudo apt-get install curl
$ \curl -sSL https://get.rvm.io | bash
# installs all the various compilers and packages you’ll need to build Ruby and common libraries
$ rvm requirements
# installs ruby
$ rvm install 2.1.1
# creates a gemset rails
$ rvm gemset create rails404
$ rvm 2.1.1@rails404
# installs the rails
$ gem install rails -v 4.0.4
# sets 2.1.1 as default ruby version
$ rvm use 2.1.1 --default

After that, install bundler.

$ gem install bundler

And last but not least install nodejs.

$ sudo apt-get install nodejs

Vagrant shares the content of your desktop folder with your vm, so you can use your desktop favorite editor, your desktop git tool and test it on your desktop browser (but you need to configure port forwarding first).

You can find more details in this tutorial.

I hope it helps.

rafaelune
  • 59
  • 6