Hi,
I'm using google-spreadsheet-ruby with Ruby-on-Rails and Ruby 1.8, but overriding String.force_encoding in GoogleSpreadsheet breaks Rails.
In a few places Rails uses this method to determine whether Ruby 1.8 or 1.9 is being used, and if force_encoding is defined then rails assumes that Ruby 1.9 is being used. This is incorrect, which can then lead to rails crashing.
Can I suggest that instead of using String.force_encoding, instead you define a new method like this:
class String
def fake_force_encoding(encoding)
if RUBY_VERSION < "1.9.0"
return self
else
return force_encoding(encoding)
end
end
end
Then change all references to "String.force_encoding" to use "String.fake_force_encoding" instead. As by doing this force_encoding is not redefined and rails will function correctly.
Hi, I'm using google-spreadsheet-ruby with Ruby-on-Rails and Ruby 1.8, but overriding String.force_encoding in GoogleSpreadsheet breaks Rails.
In a few places Rails uses this method to determine whether Ruby 1.8 or 1.9 is being used, and if force_encoding is defined then rails assumes that Ruby 1.9 is being used. This is incorrect, which can then lead to rails crashing.
Can I suggest that instead of using String.force_encoding, instead you define a new method like this: class String
def fake_force_encoding(encoding) if RUBY_VERSION < "1.9.0" return self else return force_encoding(encoding) end end
end
Then change all references to "String.force_encoding" to use "String.fake_force_encoding" instead. As by doing this force_encoding is not redefined and rails will function correctly.
Thanks!