gimite / google-spreadsheet-ruby

Ruby library to read/write Google Spreadsheet
Other
306 stars 52 forks source link

force_encoding breaks rails #2

Closed iainbeeston closed 14 years ago

iainbeeston commented 14 years ago

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!

gimite commented 14 years ago

Thanks for the report. iamruinous sent me patch for the same issue and I have already pulled that. Please let me know if it's still not fixed.

gimite commented 14 years ago

Closing...