undefined method for enumerable

johnmuhl edited this page Aug 24, 2010 · 2 revisions
Clone this wiki locally


The Radiant site is installed, properly configured and the database is correctly initialized. But the pages cannot be displayed, instead the following error message appears when you try to access a page in your web browser:

undefined method `[]' for #<Enumerable::Enumerator:0x........>

The Problem

As pointed out by Akira Yamada in this thread on the Debian Bugs Dist List, the error comes from an incompatibility between Ruby 1.8.7 and Rails 2.0.2. Ruby 1.8.7 has String#chars and returns an Enumerator object, but Rails 2.0.2 expects an ActiveSupport::Multibyte::Chars object. Since older versions of Radiant used Rails 2.0.2, these versions are also affected by this problem.

The Solution

You can either upgrade to the latest version of Radiant or apply the following fix.

Add following code to the top of the config/environment.rb file in your Radiant application.

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