Josh Symonds, Thursday, December 4, 2008 @ 2:02 am
Shamelessly dovetailing off our very own Brian Dillard's blog entry earlier this week, Pimp my jQuery, I wanted to jot down a few of my favorite Ruby on Rails tools that I would find life completely unbearable to be without. While they might seem like simple, small changes, these plugins have saved me huge amounts of time and I think the least their authors deserve are some nice shout-outs.
- QueryTrace. QueryTrace is a super simple plugin that shows exactly where SQL loads happen in your application. After an action is called you can check the log to see a backtrace after every SQL query, revealing where in your code it was referenced. Use this to find slow or unnecessary queries in your application.
- Andand. Andand is a super simple gem that allows you to simply and easily prevent NoMethodErrors: that is, it helps you catch nil objects before you send methods to them. Its use is ridiculously simple: object.andand.method. If object is nil, then method will return nil, rather than raising a NoMethodError. This functionality is actually being included in the next version of Edge Rails under Object#try, but there will always be a special place in my heart for Andand.
- Wirble. Wirble adds some awesome features to irb, and, therefore, to script/console. I've completely forgotten how I've managed to work with irb before I got tab completion, history, and colorized results. This should come standard with irb, in my opinion.
- Calendar Date Select. Somehow in almost every application I'm involved in, someone ends up wanting a quick and easy way to pick a date. It doesn't get a whole lot quicker and easier than Calendar Date Select. It's simple to use and by this point I honestly should just install it in all my projects when I start them.
- Annotate Models. Annotate Models is a very simple, small plugin that adds in a new rake task: rake annotate_models. It puts the schema for your models at the top of those models, so you don't have to use SQL queries to remember the structure of your tables. It doesn't get a whole lot simpler or more useful than this.
The beauty of small, easily digestable plugins and gems like these is that they're reusable in every application you do. Before you know it you'll be installing these before you even start serious work on a project. Got any gems and plugins you want added to the list? Throw them out in the comments!
Annotate Models now comes as a gem named “annotate-models” which provides an “annotate” command line executable.
Comment by Samuel Lebeau, Thursday, December 4, 2008 @ 3:17 am
I would rather query reviewer for trace database queries.
If you like Wirble try utility-belt from Akita, very udeful specialy for Mac users.
Comment by Seban, Thursday, December 4, 2008 @ 3:43 am
Thanks for mentioning “andand!”
Comment by Reg Braithwaite, Thursday, December 4, 2008 @ 3:15 pm
andand and annotate models are becoming quite common aren’t they?
I also like [shameless self promotion] english like queries
http://code.google.com/p/ruby-roger-useful-functions/wiki/EnglishLikeQueries
those are the three I always install [english like queries is great for the command line]
Comment by roger, Friday, December 5, 2008 @ 10:29 am
With all due respect to Reginald, he’s a really smart guy, but I wouldn’t suggest to anybody to use andand.
For what it does is super dog slow, I am talking about order of magnitude slower then a regular if statement, especially when the receive it is nil.
My suggestion is to do without it.
Comment by Diego Scataglini, Friday, December 12, 2008 @ 3:17 pm