scattrbrain
Darshan Patil's personal blog
mysql.rb errors after upgrading ruby 7
I just noticed that my rails projects broke after I upgraded ruby on my linux box. Projects that had gems and rails frozen break. This is because of code in the SHA1 class not being backward compatible.
To quickly fix a broken rails app that shows the following error:vendor/rails/activerecord/lib/active_record/vendor/mysql.rb:551:in `initialize'
edit the mysql.rb file so that the scramble41 routine looks like:
def scramble41(password, message)
return 0x00.chr if password.nil? or password.empty?
buf = [0x14]
s1 = Digest::SHA1.digest(password)
s2 = Digest::SHA1.digest(s1)
x = Digest::SHA1.digest(message + s2)
(0..s1.length - 1).each {|i| buf.push(s1[i] ^ x[i])}
buf.pack("C*")
end













