Topfunky takes on hosting

I thought I’d mention Geoff Grosenbach’s article at Nuby on Rails comparing all the major Rails hosting providers. It’s probably the most comprehensive Rails hosting guide I’ve come across, based on Geoff’s own experiences – over the years, he’s used them all. I especially wanted to point out this quote, regarding Slicehost’s $20 VPS plan:

If you are a full-time Rails developer, I think you owe it to yourself to learn how to operate a server. Spending $20/month on your own education will be worthwhile and will help you make mistakes on your own before making them on a paying client project. Slicehost would be a great environment for that kind of self-education.

I couldn’t agree more – fooling around on my VPS has been an invaluable experience. Anyways, a great read if you’re in the market for a new online home.

Elevator, a new take on Rails scaffolding

A few weeks ago Joshua Wehner, Toronto-area Rails guy, announced Elevator 0.1, his personal take on Rails scaffolding.

The key improvement? Instead of generating a public facing CRUD interface, which you’ll inevitably toss out anyways, Elevator generates both admin-side and user-side scaffolding, complete with test suite(s). As an added bonus, you also get a nicer looking pages, without approaching the complexity of something like the Ajax Scaffold gem/plugin.

See also: TorRor Google Group.

Deploy your Rails app in a subdirectory with Apache and Mongrel

It’s not particularly hard to deploy your app in a subdirectory, but I’ve found that figuring out how to can be. So, I decided to put together this short little write-up.

It turns out Mongrel versions 0.3.14.x and up have a —prefix command line parameter for locating your Rails app at an arbitrary URL. Of course, you should already be running version 1.0 anyways. Here’s a single production Mongrel instance running on port 8000, prefixed with ‘subdir’:

mongrel_rails start -e production -p 8000 --prefix=/subdir

Your app should now be accessible at http://localhost:8000/subdir.

How does this work? Aside from prefixing all your routes with the ’/subdir’ path, the —prefix option also modifies the result of all url_for (and thus link_to) method calls to include the new path. That means that, given a religious use of the link_to method, you can arbitrarily relocate your program anywhere at the drop of a hat. Not bad.

url_for :controller=> 'admin', :action => 'login' # => '/subdir/admin/login'

I’m going to assume you’ve already figured out how to proxy Mongrel through Apache. As far as your subdirectory goes, you need the following two lines in your Apache conf file:

ProxyPass /subdir http://localhost:8000/subdir
ProxyPassReverse /subdir http://localhost:8000/subdir

The “tricky” part here is to include the subdirectory in both the source and destination URLs of your proxy commands.

Anyways, that’s it. Launch your Mongrel (cluster), restart Apache, and you’re good to go.