Posts

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 branch Get a local tracking branch of the bug-fixes branch Merge the bug fix branch into master Tag the master branch with the name of the release (our deployment keys on tags) Start the automated deploy script Easy 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...

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 t...

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/proceeding s 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. Wha...

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 t...