Tuesday, August 13, 2013

Ruby -=- undefined method `[]' for #Enumerable::Enumerator

Repost from Yann Laviolette blog. I got similar problem and his solution works.

Below is his instruction:

When I upgrade to Ruby 1.8.7 I've got some problems. I'm getting the error message undefined method `[]' for #Enumerable::Enumerator.

The problem occurs with the version 1.8.7 of Ruby and it's supposed to be corrected in the version 9. To fix this problem you can either downgrade to Ruby 1.8.6 OR put this piece of code in your environnement.rb within initializer block:

 unless '1.9'.respond_to?(:force_encoding)  
  String.class_eval do  
   begin  
    remove_method :chars  
   rescue NameError  
    # OK  
   end  
  end  
 end  


No comments:

Post a Comment