Rails, Defaults and the Paradox of Choice

By Tim Kofol

Published: July 28th, 2007

Convention over Configuration. One of the main tenants of Ruby on Rails basically sets sensible defaults and forces the programmer to code only unconventional aspects of the app. To me this is one, if not the main reason Rails programming is so enjoyable.

This idea of convention over configuration reminds me of a Google Tech Talk, {if you haven’t seen any of them, they are very informative} called the The Paradox of Choice by Barry Schwartz. In his talks about sensible defaults and the happiness this brings.

The example he gives is the difference between the European and American policies towards organ donation. 28% of licensed drivers in the US are organ donors (85% think it’s the right thing to do), while in some European countries the organ donation rate is as high as 90%. What’s the difference. In Europe the default choice is that you ARE an organ donor while in America you have to opt in to be an organ donor. Basically in Europe their opinion or default is that you should be an organ donor, and you have to take measures to opt out.

So how does this relate to Ruby on Rails? Rails forces you to do the “right thing” if you do nothing. And by doing nothing or conforming to the right naming patterns you get whats in your best interest. Only when you go outside the “right thing” do you have to spend extra effort. That makes life in you mind a lot more simple, reduce choices, embrace constraints, free your mind.

AlarmTube - Alarms the YouTube way

By Tim Kofol

Published: June 22nd, 2007

I just released a little YouTube mashup called AlarmTube.

Basically what it does is it uses YouTube videos as alarm ringtones. The coolest thing about it is that it uses natural language parsing to set the alarm time (thanks chronic ). The youtube video selection support was provided by the ruby youtube gem, and the it of course uses the ruby on rails framework, which was probably overkill for this project.

Check it out at http://alarmtube.highimpactnoise.com. Trust me it is perfect for a nice thirty minute nap. Just type in 30 minutes for the alarm time and choose a YouTube video.

If you have any suggestions just email me as always at tkofol@gmail, or post a comment.

Google Apps and Rails

By Tim Kofol

Published: May 6th, 2007

I recently switched over the mailer on a project to use the gmail to send the apps emails. It is pretty well documented how get rails setup with gmail, (here and here), though you wish actionmailer could handle gmail out of the box. This could make a nice little plugin, if I get the will.

I didn’t want the email flowing through tkofol@gmail.com, so I decided to setup a google apps for you domain account. This would allow me to use something like do-not-reply@landscapesurvey.com and it would let me try out google apps.

Setting google apps for your domain was pretty easy, you just need to know how to mess around with your DNS settings or be willing to learn. I was willing to learn.

What you get is a really cool suite of webapps that if I had a small biz would be perfect. One its free, two it gives something like 100 people email accounts that end in your domain. It also has google’s word processing and excel type apps. It’s pretty solid though the online word processing and excel, still need to mature a little bit. But it is worth it just for the email accounts!

Remove WWW's from your URL

By Tim Kofol

Published: April 20th, 2007

I recently needed to redirect all the traffic from http://www.landscapesurvey.com to http://landscapesurvey.com. This was necessary because I purchased an SSL certificate that only goes with http://landscapesurvey.com and didn’t want the ugly warning message coming up if my users were using the www. version of my site.

What I consequently found out is that google is penalizing for duplicate content and considered having both the www and non www sites as duplicate content.

So after searching the internet I found that to remove the www from your url you need to put the following in your apache conf file.


RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

CSV MIME TYPE Bug in Rails 1.2.2

By Tim Kofol

Published: March 28th, 2007

For a couple of weeks I have been plagued by this annoying warning message in rails, "mime_type.rb:48: warning: already initialized constant CSV". Nothing worse than a constant ugly warning message. I would like to thank Progressive Data Solutions for ending my madness.

I had previously registered the CSV MIME type in my environment.rb, but starting in 1.2 this MIME type was added to the predifned MIME type list. But never made it out to the user due to a bug. The bug has since been fixed in the edge of rails and progressive solutions provides a nice fix for anybody using 1.2.2.

Just place the code below in your environment.rb. When the bug is finally fixed this statement will be safely ignored.

Mime::SET << Mime::CSV unless Mime::SET.include?(Mime::CSV)