December 2006
11 posts
Bustin' out "joins"
Here at t-bot we scrunitize every line of code. Here’s one from the Rails’ world.
Ok, pretend we have a site where each registered user has their own blog. Naturally we’d have the ability for you to view someone’s blog. Following a design where each model has its own controller that handles all its CRUD, we put this feature in the #show action like so:
user.rb
class User <...
What's the deal with Rails' polymorphic...
The latest big ActiveRecord feature to Rails has been polymorphic associations. Not very clear at first, I found out they’re easier to understand with a couple examples.
A common one:
class Person < ActiveRecord::Base
has_one :address, :as => :addressable
end
class Company < ActiveRecord::Base
has_one :address, :as => :addressable
end
class Address <...
SwitchTower Gotchas
If you’re using SwitchTower to deploy your rails apps (it’s fun!), you might run into these errors:
A Net::SSH authorization issue
Problems running the reaper, spinner or spawner scripts
The problems causing these errors are:
A host you are trying to deploy to is prompting you to confirm it’s ssh identify because you haven’t yet (and switchtower is choking on this)
The PATH of...
Turn down the wrong work
Thankfully, this has been getting easier lately – but I don’t think it will ever feel “normal”, and it used to be almost impossible to do. What am I talking about? Well, about not taking the wrong client work.
They say that you can either have price, speed or quality – but not all three. This may be true, but those are just the things the client wants from you. What about the things you...
2 tags
Have A Target
When you find yourself on a big team that’s been given an abstract goal with a poorly defined target – refuse to participate. If you don’t know what you’re doing or why or how it’s going to be used or who it’s going to be used by, then you can’t do anything. You can only guess about how to build a thing you’d use that’s in the ballpark of what will hopefully be requested, but you can’t be...
3 tags
Only Solve Hard Problems When You Have To
When you have the option of doing something in a complicated backwards way or a really straightforward simple way – choose the simple way. This sounds really obvious, but consistently doesn’t happen. In the same way that you should rise above the internal constraints of organizations, you can rise above the desire to do simple things in complicated ways.
Sometimes a CMS just needs to edit...
5 tags
Appear To Be Competent
While returning something to a large consumer electronics store, I had the excellent fortune of being the absolute first person in line when the computer system crashed (after standing in line for about 30 mins already). If I was returning anything that weighed less than 30 pounds, was easy to carry up stairs, fit simply into a cab, or cost less than $100, I would have left immediately – but I’d...
2 tags
Don't Use A Paintbrush When A Crayon Will Do
When you’re painting the side of your house, you need a big brush. Heck, maybe you need one of those spray-on deals that look like they’d be a lot of fun to use.
But when you’re coloring a picture of a pony, you just need a crayon – so don’t use a brush.
5 tags
Only Humans Need A Balanced Diet
Day three of my winter adventure brings us a metaphor about food.
If you eat steak every single day, you’re missing out on some critical nutrients. You may be “living like a king” (if that’s what kings eat every day), but you’re a whole bucket of fruits, vegetables and breads short of living like a normal human. The same would apply if you just ate bread, or if you just ate green beans. All...
8 tags
Find A Third Way Home
The lesson for day two in my twenty five part series is “find a third way home”. As promised, this is a vague metaphor and I’ll now provide very little explanation for it.
Often when you’re working on a large project or even on a smaller specific problem you run into situations where everyone involved in the decision-making process feels pigeon-holed into making a “black and white”...
5 tags
Doing Stupid Things Is A Choice
This is the first post in what will be possibly be a 25-part series of business mantras. Each day I will select (or possibly create on the spot) a barely-thought-out phrase, motto, slogan or saying – back it up with a flimsy circumstantial account – and steadfastly insist that it’s correct, possibly in the face of evidence to the contrary.
The mantra of today, day one in this twenty five part...