Removing framework clutter from autotest failure stacktraces

If you’re programming in Ruby, then in the list of “should be’s” is “using autotest“, assuming you’re doing automated testing, which of course is a giant “should be”. One problem if you’re using a bunch of gems or Rails is that their code works and yours is broken but the failure stacktraces you’re reading contain their method names mixed in with yours. 99% of the time this is distracting. So, using some code from Faisal that did the same thing with an older version of Autotest but doesn’t work in the latest release, I hacked up the code to help remove unwanted text from Autotest test output. And now I present it to you.
Continue reading “Removing framework clutter from autotest failure stacktraces”

Hacking rake:stats to get gross LOC

Web App Autopsy has some juicy metrics such as the 100:10:1 ratio of anonymous visitors to free registered users to paying users. But they also have LOC counts which seem quite high, and which include things that rake:stats (a Rake task that’s part of Rails, which counts lines of source code and provides some basic analysis) doesn’t count. So, I hacked rake:stats to include them. Here’s what I did:
Continue reading “Hacking rake:stats to get gross LOC”

Non-persistent Rails model classes, for easier validation

I’ve been fighting for a couple of days to learn how to best use Rails’ form validation on forms that don’t map cleanly to database tables. I think I’ve got it. The trick appears to be to use non-persistent model classes, that nonetheless inherit from ActiveRecord::Base. Here’s how.
Continue reading “Non-persistent Rails model classes, for easier validation”

First Rails gotcha: Rails doesn’t tear down fixture data

Rails doesn’t delete loaded fixtures in the tear down phase of tests, but it does delete and re-insert the fixtures you do use at the beginning of tests. This is a serious problem if you use foreign keys.

This issue is covered in the Rails issue tracker here: http://dev.rubyonrails.org/ticket/2404
Continue reading “First Rails gotcha: Rails doesn’t tear down fixture data”

Prefactoring

I have a text file full of links and notes extracted from about a month of reading everything posted to the 2 dozen Ruby, Rails, Postgres, and web tech blogs that I subscribe to via RSS. There’s so much going on in Ruby and Rails in particular, especially when it comes to convenient shortcuts that save you work, that there’s something new and cool and slightly revolutionary on a daily basis that you could use to make your app prettier.

So I’ve been in a state of analysis paralysis for about a week.

I was trying so hard to be clever and state of the art that I forgot to get something working.
Continue reading “Prefactoring”