Archive for June, 2009

serving php from a rails app with passenger

Sunday, June 21st, 2009
We have a situation where we want one domain which serves a rails app at root and also has a wordpress blog served within the main site.
yours.com/  --> served by rails
yours.com/blog --> served by php
To configure this in apache, The key is the PassengerEnabled – else passenger will try and serve the php content.

Installing Ruby Enterprise Edition on Mac OSX

Thursday, June 18th, 2009

This is quite trivial and very easy. I wanted to use the same version of ruby on my mac as is running on our production servers (Ruby Enterprise Edition).

Firstly, do a

gem list

and keep this information. You will need to reinstall all your gems once you have successfully installed REE.

Download REE from http://www.rubyenterpriseedition.com/

tar xvfz ruby-enterprise-X.X.X
sudo ./ruby-enterprise-X.X.X/installer

I suggest changing the default location to just /opt/ruby-enterprise – as you are unlikely to need to roll back the symbolic links in your development environment.

Once it is installed, then you need to make sure that you use it for all your gems, ruby, rake tasks. To do this we will sym link in all the executables into /usr/bin

Find any previous versions of ruby

whereis ruby

and

which ruby

Cleanup – backup and remove any old versions and the associated ruby, gems, rake, irb, cap, capify, erb so they are not on your path.

Then sym link from /usr/bin to opt/ruby-enterprise/bin with all the executables that you may require….

sudo ln -s -f /opt/ruby-enterprise/bin/ruby /usr/bin/ruby
sudo ln -s -f /opt/ruby-enterprise/bin/cap    /usr/bin/cap
sudo ln -s -f /opt/ruby-enterprise/bin/capify /usr/bin/capify
sudo ln -s -f /opt/ruby-enterprise/bin/erb    /usr/bin/erb
sudo ln -s -f /opt/ruby-enterprise/bin/gem    /usr/bin/gem
sudo ln -s -f /opt/ruby-enterprise/bin/irb    /usr/bin/irb
sudo ln -s -f /opt/ruby-enterprise/bin/rails  /usr/bin/rails
sudo ln -s -f /opt/ruby-enterprise/bin/rake   /usr/bin/rake
sudo ln -s -f /opt/ruby-enterprise/bin/rdoc   /usr/bin/rdoc

Do a gem list to see what ruby-enterprise came bundled with.

Now you will need to install all your gems again – that you noted earlier.

rails legacy database migration

Thursday, June 4th, 2009

Just migrated a legacy database into a rails compliant database – and wrote this nifty DSL script to help out….

The rake task generates the Hash data for the table creation, data insert and rollback scripts.

Once you run the rake task, paste the output into the migration modify the update table and column names – then run the migration.