evan / has_many_polymorphs

An ActiveRecord plugin for self-referential and double-sided polymorphic associations.
http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/
Academic Free License v3.0
201 stars 57 forks source link

commit bacaeb095f..., 'fix invalid byte sequence...' breaks gem on ruby 1.8.x #8

Open stepheneb opened 15 years ago

stepheneb commented 15 years ago

The new code in question is:

open(filename, :encoding=>"utf-8") do |file|

the error reported is:

open-uri.rb:32:in `initialize': can't convert Hash into String (TypeError)

The same error occurs using File.open:

File.open(filename, :encoding=>"utf-8") do |file|

Presumably this only works in Ruby 1.9. I'm building Ruby 1.9 now to check. In the latest Pickaxe book this is the method described for setting the encoding to utf-8 when using File.open:

File.open(filename, 'r:utf-8')

This method also doesn't work in 1.8.x

Also see comments on this commit:

http://github.com/fauna/has_many_polymorphs/commit/bacaeb095f5e8cf7427679b2755680ab24f8503e

stepheneb commented 15 years ago

reverted in this commit in a fork:

http://github.com/stepheneb/has_many_polymorphs/commit/fd531f3310b2fbcf06a9e46e7fe55d71f5585ae3