-
Notifications
You must be signed in to change notification settings - Fork 6
Cloud9 workspace setup with Rails and Postgresql
new custom private workspace
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
curl -L https://get.rvm.io | sudo bash -s stable --rails
The console might output a couple of warnings. You must amend .bash_profile to source ~/.profile, and unset the current gem set. Open ~/.bash_profile (click the "Show Hidden Files" button if .bash_profile isn't visible) and add the following line.
source ~/.profile
or, for simplicty, run this line on your command line:
echo "source ~/.profile" >> ~/.bash_profile
Then run the following command in the console.
unset GEM_HOME
add the following to your gemfile:
gem 'pg'
and run the bundle command
bundle install
change your database.yml file with the following:
default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: <%= ENV['USERNAME'] %>
password: <%= ENV['PASSWORD'] %>
host: <%= ENV['IP'] %>
development:
<<: *default
database: app_development
test:
<<: *default
database: app_test
production:
<<: *default
database: app_production$ sudo service postgresql start
$ sudo sudo -u postgres psql
postgres=# CREATE USER username SUPERUSER PASSWORD 'password';
postgres=# \q
$ echo "export USERNAME=username" >> ~/.profile
$ echo "export PASSWORD=password" >> ~/.profile
$ . ~/.profile
$ sudo sudo -u postgres psql
postgres# UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
postgres# DROP DATABASE template1;
postgres# CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
postgres# UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
postgres# \c template1
postgres# VACUUM FREEZE;
postgres# \q
Enter the following at the terminal prompt to create aliases for commands. The aliases will be appended to your Cloud9 workspace .bashrc file. The final command will reload .bashrc into the current environment so you don’t have to log out and back in for the aliases to take effect.
$ echo 'alias server="rails server -b $IP -p $PORT"' >> ~/.bashrc
$ echo 'alias guard="bundle exec guard"' >> ~/.bashrc
$ . ~/.bashrc
Enter the following to avoid installation of gem documents.
$ echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc