From 0f15901151beb06f7b04f85a89f32ce8e2e506b7 Mon Sep 17 00:00:00 2001 From: noi narisak Date: Wed, 3 Sep 2014 16:39:28 -0500 Subject: [PATCH] initial rails-dev-box vagrant implementation --- NOTES.txt | 59 +++++++++++++++++++++++++++ README.md | 11 +++++ README.rdoc | 28 +++++++++++++ Vagrantfile | 6 ++- etc/postgres/enable_utf8_template.sql | 16 ++++++++ 5 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 NOTES.txt create mode 100644 README.md create mode 100644 README.rdoc create mode 100644 etc/postgres/enable_utf8_template.sql diff --git a/NOTES.txt b/NOTES.txt new file mode 100644 index 0000000..7dbc002 --- /dev/null +++ b/NOTES.txt @@ -0,0 +1,59 @@ + +* Road blocks and fixes: + +##- When trying to do 'vagrant plugin install vagrant-vbguest' got the follownig nokogiri error. Vagrant v1.6.3 on OSX 10.8.5. + + Installing the 'vagrant-vbguest' plugin. This can take a few minutes... + Building nokogiri using packaged libraries. + Building libxml2-2.8.0 for nokogiri with the following patches applied: + - 0001-Fix-parser-local-buffers-size-problems.patch + ... + ... + ... + Bundler, the underlying system Vagrant uses to install plugins, + reported an error. The error is shown below. These errors are usually + caused by misconfigured plugin installations or transient network + issues. The error from Bundler is: + + An error occurred while installing nokogiri (1.6.3.1), and Bundler cannot continue. + Make sure that `gem install nokogiri -v '1.6.3.1'` succeeds before bundling. + ... + ... + +- Workaround +$ export NOKOGIRI_USE_SYSTEM_LIBRARIES=true +$ vagrant plugin install vagrant vagrant-vbguest +$ vagrant plugin list (validate install) + + +##- Executing "rake db:create" you get the following errors + PG::Error: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) + HINT: Use the same encoding as in the template database, or use template0 as template. + : CREATE DATABASE "db/bikedb_development" ENCODING = 'utf8' + +- Solution: follow the instructions here +http://journal.tianhao.info/2010/12/postgresql-change-default-encoding-of-new-databases-to-utf-8-optional/ + + +## UPDATE - 2014.09.03 +Implemented a simple psql script that does the exactly as the url above. Do the following inside guest-OS + +$ vagrant ssh + +$ psql -d postgres -f /vagrant/etc/postgres/enable_utf8_template.sql +$ sudo -u postgres psql postgres + +postgres=# \l + +(The ENCODING should be UTF8 for 'template1' database) + + +Original resources for the Vagrantfile. +http://gorails.com/guides/using-vagrant-for-rails-development + +========================================= + +## TODOs ## +- Add the etc/enable_utf8_template.sql into Vagrant provision routine. One less task to for developer to execute. +- Create developement instructions (README.rdoc?), outlining the commands get the Vagrant/Bike-DB up and running. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..36409fc --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +#bike-db +============= +Bike-db is an open source project that aims to helpcommunity bicycle projects track bikes, clients, and volunteers. + +Bike-db is a Ruby on Rails project. The database used is PostGres. + +An instance can be seen running at http://secret-earth-4230.herokuapp.com/ + +The storyboard / feature list is at https://trello.com/b/ZCZ9sThH/bike-db-app + +Feel free to request feature additions! \ No newline at end of file diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..acf26f9 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile index f26328d..9888691 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -20,9 +20,11 @@ Vagrant.configure('2') do |config| v.customize ['set', :id, '--on-window-close', 'keep-running'] end + # Enable, if you are NOT OSX. # config.vm.synced_folder '.', '/vagrant', type: 'rsync' - # Enable if you are on OSX - config.vm.synced_folder '/src', '/vagrant', type: 'nfs' + + # Enable ,if you are on OSX for increase performance. NOTE: May require Admin password + config.vm.synced_folder '.', '/vagrant', type: 'nfs' config.vm.network :private_network, ip: '33.33.33.33' config.vm.network :forwarded_port, guest: 3000, host: 3000 diff --git a/etc/postgres/enable_utf8_template.sql b/etc/postgres/enable_utf8_template.sql new file mode 100644 index 0000000..cf3ab24 --- /dev/null +++ b/etc/postgres/enable_utf8_template.sql @@ -0,0 +1,16 @@ +/* +* Updates the default 'template1' database into UTF-8 instead of SQL_ASCII. +*/ + +UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1'; + +DROP DATABASE template1; + +CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE'; + +UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1'; + +\c template1 +VACUUM FREEZE; + +UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';