Wilcox Development Solutions Blog

My Base Rails Setup

June 28, 2010

I’ve been working with Rails for 2 years now, and I’ve developed a collection of tools I really like. I’m going to share these with you (eventually I’ll make a Rails template for them, but not now).

Normal Application Stack

  • will_paginate

  • formtastic: this really cuts back on the amount of HTML I have to write, and, having the input type defaulted from the column type is nice I can also script/generate form $MODEL, which is awesome.

  • DataMapper: I haven’t had a project to use this on yet, but this is my preferred ORM.

  • sentient_user: I very often need to know who the current user is when I’m in my models.

    Yes, I can avoid some of this by querying through the controllers, but sometimes you just need to know who your current user is.

    Instead of worrying about what the latest fashion is in the Rails community, I’ll just let some common code.

  • show_for. Formtastic for show actions.

  • My annotate_models port: I finally have an annotate_models that works exactly like I want it too. That’s the great thing about Github: the easy network graph.

  • Inherited Resources: I really don’t like code in my app that just boilerplate (especially auto generated boilerplate). The boilerplate just gets in the way if I have to customize the controller or view, and just needlessly brings up the line count if you don’t.

  • Data Migration: I don’t like putting data changes in the migrations, and db/seed.rb sucks if you add data to it (you have to be careful to not add duplicates!). Data migration gives us a way to add data to a production system in the same way we might add/chage schema

Inherited Resources is great, especially when the controller is in an early stage of development or an admin controller that might not matter.

If the code’s not there I won’t have to maintain it at some point in the future.

On the testing front

  • shoulda. I like the simplicity of Test::Unit, but I don’t like typing def test_the_object_should_error_when_the_date_is_invalid_my_fingers_are_bleeding_ackk. Shoulda context and should blocks makes this a lot easier.
  • timecop. I love Timecop.
  • machinist. The tagline says it all: fixtures aren’t fun, Machinist is.

Utilities

  • Mailtrap: enough of mail server to handle ActionMailer communications… and log them to a file.
  • rr: easy mocking framework
  • jQuery’s timeago plugin: I hate websites that say “created 5 minutes ago.” Do you mean 5 minutes from now, or 5 minutes from when I last refreshed the page? Use some Javascript to avoid this question
  • BlueprintCSS
  • utility_belt: make IRB way more useful.

Hopefully there’s one or two new things in here for you to add to your Rails setup!


Tagged with:

Written by Ryan Wilcox Chief Developer, Wilcox Development Solutions... and other things