Friday, January 9, 2009

Prune those plugins, you could die anytime

In Zen practice it is customary to clean your meditation cushion before standing and leaving the Zendo. The reason for this is to remind you that you can die at anytime and you want to leave the cushion in good condition for the next person.

Projects can accumulate extra plugins and gems that developers thought they were going to use. All gems plugins represent a risk of not aging well. Many gems put subtle hooks into Rails that can muck up the works and create a hard bug to track down.

Another reason to do this is prevent future developers from guessing wether a gem is in use or not. It sucks to upgrade a or even manually fix a broken gem when it isn't even being used.

So prune those plugins, you could die anytime.

Monday, January 5, 2009

Common Dreamhost Git Capistrano Deployment Problem

So you finally got your Capistrano deploy.rb script setup for Dreamhost and you have your deploy key configured on your Github project. Yet when you cap deploy your project it can't check out the code from Github to your Dreamhost server.

Well, the solution is to just log into your Dreamhost account where the project is going to be hosted and do a git clone of your project to test if it works.

What will happen is that you will get the standard ssh verification question asking if you want to login to this new server. (Answer yes!)

Do that once and you should have solved at least that obstacle in your deploy.rb

Deploying a Rails Edge(2.3.0) Project to Dreamhost

So I deployed a new edge based Rails project to Dreamhost. And Passenger gave me a problem.

The answer was to rename the application_controller.rb to the old application.rb name. Now the app works in both 2.3.0 and 2.2.2 so there.

Sunday, January 4, 2009

Common patterns: Using the body tag class to set state for CSS rendering

This is a pattern that I use often. I just throw this function into my application helper file.




I throw this into the application_helper.rb file because I inevitably want to add more state to the body tag of a given project. I use these CSS classes to set my tabs up in a css file or hide certain things from people who are not logged in, etc.

For example: