Getting a Ruby Application Working on HostMonster

I recently bought an account to run my Ruby web sites at a place called HostMonster. This promised to have out of the box support for Rails – it seems trivially worth $120 for a year to save having to figure it all out myself.
I worked through their pretty clear knowledge base article. I created my tables using rake db:migrate instead of hand-making the tables in MySql – because I like abstractions!
I got the DB working and then when I clicked on “About your application environment” on the Welcome to Ruby page, I got my 500 error:
Application error
Rails application failed to start properly”
Nothing in the logs at all – it was clearly not starting Ruby – I was sure it was a little configuration error. I made a few fresh apps with the same results over and over.
So I called technical support – they really answered after about 5 monite on hold – the guy on the phone was not on a rails expert – he said to make a trouble ticket – which I did. Several days later I got a kind of generic – “did you look in the knowledge base?” response from Level 1 support. Grrrr. Yes – only for about 4 hours! And searched the forums and searched Google, and hacked my .htaccess etc etc.
I snarked back at Level one support repeating the problem – I told him that I just tried it *again* and it still was not working.
Then 9 days later I get a nice note from Level 3 support asking if it was all fixed – he checked my site and he though it was OK. I said “no it was not” and that I was tired of trying. I was about to think of my $120 as sunk cost and go to Deamhost where my pals have things working and so I could at least look at their stuff.
One day later the Level 3 guy (Thanks Jacob) got back with me with this message:
There were just permissions issues within the rails application. I tested imsti.rubylearn.com and is working now. You can’t view the application’s environment using the link from the default public page for security but it no longer give an error about the application failing. Also I would suggest using the dispatch.fcgi in your configurations.
I looked at the working directory and one that was broken and the problem was that my umask on UNIX had left group write permission all over the place. And Apache was silently saving me from a life of being hacked. I quickly did a hack on my other dirctory:
chmod og-w public
chmod og-w public/*
chmod og-w public/*/*
And my old directory started wrking slick as you please! Damn – I *knew* it was something simple.
Now I have to do this all the time so I whipped up a little C-Chell script that I now run in each newly minted rails application. Here is my script called fix-perm.csh
#! /bin/csh
foreach i ( ` find . -print` )
echo chmod ag-w $i
chmod og-w $i
end
I keep this in my rails_apps directory and use it like this:
cd ~/rails_apps
rails appnew
cd appnew
csh ../fix-perms.csh
Viola! Please let me know if this works for you. I wish that Hostmonster would add this to their knowledge base.
Just to be clear when you press “About my application environment” and see this message:
For security purposes, this information is only available to local requests.
This is working *properly* – it means that Ruby is running and giving you the message instead of RUby failing so you see the 500 error (above).
Again – thank to Jacob who did not give up – I was quite patient because I was busy on other stuff and glad they did not let the ball drop. Thanks HostMonster.