Monthly Archives: August 2009
Judging Rails Rumble
So after doing having the great honour of doing the preliminary design for Rails Rumble, It has just been announced that I am joining some amazing people and judging Rails Rumble aswell. It’s a great privallage and I look forward to judging your apps.
Unless.nil? – Down with double negatives
This is a very small tip aimed for people to clean up their code-base and remove some of the double negatives.
Often I shall see:
unless @user.nil?
The issue with this is approach is that unless is harder to read than if, then you have to mentally process the #nil?
The other approach is:
if @user
However, for a lot of people this is not explicit enough. I find that too few know about #present? method
if @user.present?
#present? is literally the opposite of #blank? and thus checks if it is not nil? or if it is not empty?
Hopefully with this small tidbit of knowledge, you can clean up your code and make it easier to read.
Deploying Thinking Sphinx with Capistrano
I’ve had a lot of issues trying to deploy ThinkingSphinx with Capistrano. This has been for a multitude of reasons. The following is my recipe for deploying and hopefully making it public will make a few people’s lives easier.
This assumes you are using the plugin, not the gem.
In your deploy.rb, add the following at the top:
require 'vendor/plugins/thinking-sphinx/lib/thinking_sphinx/deploy/capistrano'
Then, at the bottom add this: