ruk·si

🛤️ Ruby on Rails
Running on Windows

Updated at 2016-01-07 22:49

Don't install Ruby on Rails on Windows, use a virtual machine. There are multiple Ruby gems that have poor Windows support as they are released, especially the ones that require building like nokogiri. It's just a lot less hassle if you use some Linux VM to run your Ruby environment.

  1. Install Vagrant
  2. Install VirtualBox
  3. git clone https://github.com/rails/rails-dev-box.git
  4. cd rails-dev-box
  5. vagrant up
  6. vagrant ssh
  7. sudo chgrp -R vagrant /var/lib/gems /usr/local/bin
  8. sudo chmod -R 0774 /var/lib/gems /usr/local/bin
  9. gem install rails -no-ri --no-rdoc
  10. cd /vagrant
  11. rails new rallod
  12. cd rallod
  13. bin/rails server -b 0.0.0.0
  14. Go to http://localhost:3000/ with your browser.
echo "web: bundle exec rails server -b 0.0.0.0" > Procfile
gem install foreman
foreman start
# add following to Gemfile
gem 'pg'
bundle install
# edit `config/database.yml`
default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  host: localhost
  database: rallod_development
  username: rallod
  password: rallod

test:
  <<: *default
  host: localhost
  database: rallod_test
  username: rallod
  password: rallod
# sudo vim /etc/postgresql/9.3/main/pg_hba.conf
# replace content
local   all         postgres                          trust
local   all         all                               password
host    all         all         all                   md5
# sudo vim /etc/postgresql/9.3/main/postgresql.conf
# find and edit
listen_addresses = '*'
sudo service postgresql restart
createuser rallod -s
psql -Upostgres postgres
ALTER ROLE rallod WITH ENCRYPTED PASSWORD 'rallod';
bundle exec rake db:create
bundle exec rake db:create
bundle exec rake db:drop
bundle exec rake db:migrate
# test the database connection yourself
psql --username=rallod -p 5432 rallod_development
\conninfo

Use pgAdmin to inspect the database. Open the virtual machine and add port forwarding from 5432 to 5432. Download pgAdmin. Add new connection on pgAdmin: localhost:5432 rallod:rallod