Tuesday, March 20, 2012

Ruby hash to_xml residue

When using the to_xml on a ruby hash object, it leaves a root.
The way to get rid of it is by explicitly specifying the root by the following:


my_hash_object = {:a=>"a", :b=>"b"}
result = my_hash_object.to_xml(:root=>"new_root")

And that's what its all about.

Wednesday, March 14, 2012

Pie Day


There aren't many special days for the non believers. But today is.
Its a day for celebrating irrationality at its best. Although not as interesting as e-day (Feb 7th at 6pm) and some what disproportionate compared to gold ratio day (Jan 6th at 6pm)
Still, its special.

Sunday, March 4, 2012

Morning comes as pure delight

After spending the night working, I went for a ride along the Tel Aviv shore line. The sky was a bit clearer after the heavy rain.

Rinsing rain, under skies so bright,
Sleep all day and work all night
Morning comes as pure delight

I hope I'll manage to do some testing before my head crashes into the keyboard.




Thursday, March 1, 2012

Installing RoR 3.x on Ubuntu 10.4 with MySQL

I'm writing this as a reminder for myself.
To install Rails (3.x) on Ubuntu 10.4 with a MySQL gem do the following:


sudo su
apt-get install build-essential
apt-get install ruby rdoc libopenssl-ruby
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar zxvf rubygems-1.3.7.tgz
cd rubygems-1.3.7
ruby setup.rb
ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo apt-get install ruby1.8-dev
gem install rails

To install the MySQL gem: 

apt-get install ruby-dev libmysql-ruby libmysqlclient-dev
gem install mysql


After creating the application using
rails new myApplicationName -d mysql
Running the rake db:migrate will result in error, since it requires a JS engine.
To fix that, edit the Gemfile in the application directory and add the following lines:


gem 'execjs'
gem 'therubyracer'

and then run
bundle install

* Another option is to install NodeJS on the machine, as the javascript engine by following these steps:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
.