Posts

Showing posts from May, 2009

Finding a Rails Route from a Path

Fred Polgardy and I were looking up how to find out what path in the browser corresponds to what controller/action combination in a Rails application today and I realized that I've looked this up before... So I'm putting this information here so I can find it in the future:
(from inside the console) >> ActionController::Routing::Routes.recognize_path '/seo/hotness/path/705105' => {:controller=>"products", :action=>"show", :id=>"705105"}
Yeah I know you can do a 'rake routes' and hunt around but this gets me where I need to be quicker.

Delete Like a Crazed Madman

Lately I've been working with this guy Felix who likes to rip the application into shreds when confronted with a problem. Initially, it's a bit scary. I know we have source control and we can get it all back, but ripping out large crucial swaths of code just seems so violent and yet it's a pretty effective strategy.

On this one project we've had a problem for well over a year of our tests not rolling back the database after each test. We've got all the configuration set up for that to happen, but it just doesn't and nobody could figure out why. One of the problems is that this is a Rails application that is 2.5ish years old and serves millions of users every day. So in order to make that happen back in the early days of Rails we had to extend and modify a lot of the Rails framework. Apparently one of those modification broke the mechanism for rolling back the database after every test.

Not rolling back the database means that one tests creation/updating of …

Git isn't Chatty

Recently we deployed to production without a key bugfix and my assumptions about git were to blame.

We, like other people who use git, do a lot of our bug fixing in a branch and then merge it into master when it's time to release. So here's the procedure for the guy who's turn it is to do a deploy (which was me):
Do a 'git pull origin master' in the master branchGet a local tracking branch of the bug-fixes branch Merge the bug fix branch into masterTag the master branch with the name of the release (our deployment keys on tags)Start the automated deploy scriptEasy right? Except that my years with subversion have put in my brain this assumption that my source control will talk to the remote server all the time. But git's model is to use all your local info unless you specifically tell it to go over the wire. So when I told git to create a local tracking branch it did using the latest information it had locally about that branch. The last time I had done a gen…

iMeow

So my friend Leah has lots of ideas. And one of them was that people would pay money for a screeching cat sound on their iPhone.

Everyone within earshot thought about it and the consensus was that, yeah, I might pay a dollar for that. So Leah and I set about working on the iMeow application but the iPhone development one-two punch of dragging/clicking and Objective-C soon drove us to despair. I, the lessor developer, gave up but she stuck with it (and pulled in some other Obtivians with iPhone knowledge such as Turner, Nate, and others who I'm probably forgetting) so I'm proud to present iMeow (iTunes link).

It's a silly little good time.

Rails Conf 2009 Third Day of Sessions

Last night I chose quantity over quality and ate at a Brazilian steak house. Good times.


Webrat: Rails Acceptance Testing Evolved Bryan Helmkamp (weplay)

Bryan started out his presentation by handing out Tylenol for those who went out last night and Budwiser for those who didn't. The crowd was appreciative.

Bryan show some typical Rails integration testing (simulating clicking through the app without opening up the browser) and compared it to the same test in Webrat. The difference between the integration test and the webrat enabled test was pretty dramatic. The Webrat test was much cleaner and easier to read.

Webrat parses the returned html with Nokogiri (which he highly recommends) and so can do some pretty interesting stuff. click_link, fill_in, check (and uncheck), choose, select, attach_file, and click_button all have a simple syntax.

Webrat automatically is checking for the success of the request so you don't have to assert success everywhere. It also verifies that …

Rails Conf 2009 Second Day of Sessions (Evening)

If you're looking for the slides from my talk, you can find them (and everyone else's) here:
http://en.oreilly.com/rails2009/public/schedule/proceedings

I feel like I must confess to you, faithful blog readers, that last night I ate a $240 steak at CraftSteak. But I do not apologize -- It was worth it.

Before I give anyone at Obtiva a heart attack I should point out that I will not be expensing that meal.

Also, have you seen Toby Tripp's Meeting Ticker? (http://tobytripp.github.com/meeting-ticker/) You enter your billable hourly rate, the number of people in the meeting, and press start. It then counts up the amount of money wasted, er, spent. Useful for those clients who are addicted to meetings.

Now on to the keynote:

What Killed Smalltalk Could Kill Ruby Too Robert Martin (Object Mentor Inc.)

First of all it's probably worth tracking down the video of this talk and watching it. Uncle Bob is a crazy talented speaker who knows way too much about software.

What was it…

Rails Conf 2009 Second Day of Sessions (Afternoon)

My talk (Using MetricFu to make your Rails code better) went well. I'd say there were 200ish people in the crowd and they all seemed to enjoy it. There were a bunch of questions and some verbal commitments to contribute to MetricFu.


Rails in the Large: How We're Developing the Largest (Enterprise) Rails Project in the World Neal Ford (ThoughtWorks), Paul Gross

Full disclosure: Paul and Neal are friends of mine from my ThoughtWorks days.

The talked about the trials and tribulations of developing a very large Rails project over a few years. The project is called Online Vehicle Exchange (OVE) and it's a sort of EBay for car dealers (it isn't open to the public).

The have 11 dev pairs (22 devs). And started out with mac minis but later switched to mac pros -- they probably should have switched over earlier.

Testing:
Fully disconnected unit tests. They use UnitRecord (which reads your schema.rb file to). If you accidentally hit the db then UnitRecord fails the test

They…

Rails Conf 2009 Second Day of Sessions (Morning)

Sponsor Keynote: Agility in Deployment - Rails in the Cloud Jon Crosby (Engine Yard)

During the morning session Engine Yard announced their new Rails on EC2 (Amazon's compute cloud) solution: Flex

You can one button deploy to the cloud. It is a self healing cluster: Each node is in a load balancing pool. If one fails they automatically startup a new one to take over.

It can use a web interface or capistrano.

You can create a clone of the whole production environment with the data. So you can practice deploying to your cluster. Then you can blow away the staging environment when you're done with it. Nice. Keeping a staging environment around all the time is very costly if you want it to accurately simulate your production environment.

Flex will be available in June


Chad Fowler then introduced Chris Wanstrath for his keynote. While introducing him he mentioned that when he first saw git he didn't like it much. But he, and a lot of others, adopted it because of Github. …

Rails Conf 2009 First Day of Sessions (Evening)

Ruby Heroes Award Ceremony Gregg Pollack (Rails Envy)

Gregg gave out the Ruby Heroes Awards:

Brian Helmkamp for Webrat
Aman Gupta for EventMachine and AMPQ
Luis Lavena for One-click Ruby Installer (for Windows)
Pat Allen for Rails Camp and thinking_sphinx
Dan Kubb for DataMapper
John Nunemaker for HTTParty and RailsTips (the blog)


Keynote Timothy Ferriss (The 4-hour Workweek)

The keynote was run as a conversation between David Heinemeier Hansson and Tim Ferriss.

Tim worked from 7am to 9pm when he realized that his income had no meaning. He took some time off and during that time he limited his work to 2 hours every Monday of checking his email. Profits went up 30%. Turns he was way over managing everything.

I've read the 4-hour work week and it's a fun and wild ride. The title is a bit of an eye-grabbing misnomer. It's more about viewing time as valuable commodity.

Tim practices an information diet. There's way more information in this digital world than you can possib…

Rails Conf 2009 First Day of Sessions (Afternoon)

Did you know the Las Vegas Hilton charges you 3 dollars to print out a boarding pass? Jerks.

JavaScript Testing in Rails: Fast, Headless, In-Browser. Pick Any Three. Larry Karnowski

So blue_ridge is a javascript testing tool that mashes up a bunch of other tools to make testing javascript more or less like writing RSpec test. It's pretty cool. It uses Screw.Unit for the RSpec like lingo, Smoke for mocking, and Rhino to run the javascript tests without a browser (so you can integrate it into your Cruise Control build).

http://github.com/relevance/blue-ridge/tree/master

Blue-ridge is JQuery opinionated but can use Prototype without too much trouble.

It has a textmate bundle so you can run your javascript tests with command-r

You can have multiple describe blocks like RSpec.

Definitely worth a look.


Smacking Git Around - Advanced Git Tricks with Scott Chacon (GitHub)

Scott is very smart and really funny but he talked very fast so if you want to see the full slide deck you can go to:

http:…

Rails Conf 2009 First Day of Sessions (Morning)

Quick note: What's up with all the moths in this convention hall? They keep wandering over to see what I'm typing. Odd.

David Heinemeier Hansson's Keynote:

Here are some thoughts expressed by David during his keynote:
You can win argument merely based on the strength of your arguments, most often it just takes some time for good ideas to sink in.

7 Reasons I switched back to php (Derek Silvers) and the Twitter Fail whale (Twitter's scaling problems with Rails) were pretty big issues -- for about 2 days on Digg/slashdot. His strategy with this is to relax, read the credible info and learn. Criticisms about Rails scaling will never go away despite all the high profile successes.

Merb was the most credible internal (from inside the community) competitor/critic. And now they are merging in Rails 3.

Philosophy of Rails 3:
Lock up the unicorns... huh? You can't get every feature you want and still release before the end of the world.

No sacred cows. If you want to break e…

Tutorial Day at Rails Conf 2009

First off, I'm going spend a minute in non-technical land and say that my wife and I had a fabulous time in Vegas over the weekend. She got to be part of a magic trick at the Penn and Teller show and won 50 bucks from a Wizard of Oz slot machine. Here's some pics of our trip in case you want to see: http://www.flickr.com/photos/7589554@N02/sets/72157617613438444/

The first tutorial I attended was "Running the Show: Configuration Management with Chef" by Edd Dumbill. Poor Edd had a demo involving talking to machines across a network and it didn't go well early. Live coding, combined with installing through the internet, and setting up a local intranet was sort of a triple threat. Any one of those is hard to pull off in front of a few hundred people and all three proved too much. We took a break an hour and a half in and the network issues were mostly worked out.

Chef seems to be sort of a very intense Capistrano. What if you wanted to deploy your app to a ba…