Rails developer in Seattle available

31 Jan 2007

If you are looking for a Rails developer to do some work for you, someone who has written the book on doing e-commerce with Rails :), and who has experience in every aspect of designing, developing, and deploying Rails applications, do get in touch. I’m available for projects large and small, near and far.



Meet up at RailsConf 2007

12 Jan 2007

I just launched a ConferenceMeetup site for RailsConf 2007. As I wrote in my post announcing ConferenceMeetup, this was an app inspired by what I wish I would have had when I attended RailsConf 2006 and RubyConf 2006, and I hope others attending RailsConf this year will find it useful.

If you’re planning on attending RailsConf this year, you’re welcome to create a page for yourself at the RailsConf 2007 ConferenceMeetup site. You’ll need to enter the conference password to create your account. The password is “chunky bacon” (without the quotes). With the huge turnout that’s expected to be at the conference, this may be the best way to “bump into” the people you’d like to meet while you’re there.

If you have comments or suggestions about the site, I’d love to hear them. Feel free to let me know what you think.



Finding bugs with irb

2 Jan 2007

There has been a lot of irb love happening lately, and I’m lovin’ the irb, too.

After launching a Rails e-commerce application recently, I was taking a look through the database just to make sure things were working as expected. Lo and behold, I found a problem. Something funky was happening with a small number of the orders. Time to dig in.

The problem centered around calculating discounts, which calculations can be affected by a number of variables present at the time of checkout: the particular items in the cart, the discount code used, etc. In other words, it would be somewhat difficult to work out what should have happened versus what actually happened by taking the relevant data and doing the calculations by hand. In this case, it would be much easier to actually poke at the transactions in question and play with the code as it would have interacted at the time of the transaction. Rails console to the rescue!

$ ./script/console
  >> irb Sale.find(:first, :conditions => "something’s not quite right")
  >>

What’s that you say? Invoking irb from inside irb? Madness! What does it do? It loads another session inside your current session, and now self points to the results of that Sale.find. Why is this so useful? Well, suppose you have an instance method in the Sale class that does a lot of calculations, pulling in the related discount, related line items, etc., and it has references to self.this and self.that all over the place in there. With a little help from this irb sub-session, now you can play with that code as it was written, and (in this case) as it was executed against the instance when the instance was first created.

So, with this powerful tool in hand, and a little time poking at the discount calculations, I found my problem, wrote a test that reproduced it, fixed it, and repaired the affected transactions. Yay irb!