Skip to content

Category Archives: Uncategorized

chicken and egg

I can’t believe this still hapens. Unzip software that is zipped. I was trying to unzip a file off of the web to install on my palm and they had zipped the 15k zip prc file to save those few extra bytes on the web making it impossible to actually download and use the software [...]

testing named scopes

Named scopes are a nice feature that came out in rails 2.1, however, testing them is not very obvious.
Say we have a named scope in our member object which looks like this:

class Member < ActiveRecord::Base
named_scope :active, {:conditions => {:status => Member::STATUS_ACTIVE}}
end

There are 2 things we need to do to test them.
First would [...]

Mysql issue with rails and antivirus on windows

abstract_adapter.rb:150:in log’: Mysql::Error: Can’t create/write to file ‘C:\MySQL5\tmp\#sql_190_0.MYI’ (Errcode: 13)
I had been getting this issue quite a bit recently. The cause actually turned out to be a conflict between McAfee and MySQL. What was happening is that McAfee scans any file that is recently written to, especially those in tmp directories. McAfee reading the file [...]

testing protected and private methods in ruby

When I was looking for how to test protected an private methods in ruby on the net, I found many sites arguing whether you should, and several methods for doing so. I am of the opinion that if your method contains any logic at all, it should have a test. Some examples of what I [...]

new has_a block

Pretty simple post, but any ruby object can be post conifged in a line with somthing like:
User.new(:name => “tony”){|u| u.save}
which is great for active record tests.
Or in a bigger example:

@trip = Trip.new{|t| t.save!}
@invite1 = Invitation.new(:user => users(:aaron),
[...]