AR/SQLServer: Legacy column names with embedded spaces

I'm working against a legacy (which means I can't change the table or move to MySQL ;]) table in a SQL Server database that has column names with embedded spaces in them (see error messages below).

When I go to delete one of these records I get messages like the ones below for every column with any embedded spaces.

<snip>

Exception occured during reader method compilation. Maybe Date Code 3 is not a valid Ruby identifier? (eval):1:in `evaluate_read_method': compile error (eval):1: formal argument cannot be a constant

def Date Code 3; raise NoMethodError, 'missing attribute: Date Code 3', caller unless @attributes.has_key?('Date Code 3'); @attributes['Date Code 3']; end

Wes,

These errors are thrown by ActiveRecord::Base when it tries to create attribute accessor methods. As you can see, it's trying to define a method 'Date Code 3' which is an invalid method name due to the spaces within the name. The fact that DB column names can map to object attribute names is a fundamental assumption of ActiveRecord, and hence not an easy thing to overcome. The best solution I can think is to develop a plugin to map attribute names used in your database to valid method names and patch your version of active record to use this mapping.

Tom