guard for #define_read_method in active_record/attribute_methods/read.rb

Hi,

I got this error today:

/home/jan/.rvm/gems/ruby-1.9.2-p136/bundler/gems/rails-8adfede96e26/activerecord/lib/active_record/attribute_methods/read.rb:74: syntax error, unexpected ‘;’
…); (v=@attributes[‘name’]) && ; end; alias name _name
… ^
/home/jan/.rvm/gems/ruby-1.9.2-p136/bundler/gems/rails-8adfede96e26/activerecord/lib/active_record/attribute_methods/read.rb:74: syntax error, unexpected $end, expecting keyword_end
…e’]) && ; end; alias name _name
… ^

because cast_code in active_record/attribute_methods/read.rb#63 may be empty string.

Attachment is a possible patch.

Thanks,
Jan

define_read_method.patch (906 Bytes)