🛤️ 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.
- Install Vagrant
- Install VirtualBox
git clone https://github.com/rails/rails-dev-box.git
cd rails-dev-box
vagrant up
vagrant ssh
sudo chgrp -R vagrant /var/lib/gems /usr/local/bin
sudo chmod -R 0774 /var/lib/gems /usr/local/bin
gem install rails -no-ri --no-rdoc
cd /vagrant
rails new rallod
cd rallod
bin/rails server -b 0.0.0.0
- 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