I had been setting up a test server yesterday for one of the app I am working on. Setting up Rimuhosting went smoothly and I was able to see this new baby online. I was happy and started testing. But just after 1-2 clicks i started getting the page. “We are sorry but something went wrong” …
:O :O :O
How did this happen???? it was working fine locally????
Well i know it happens so i checked the log. It said ActionView::TemplateError (undefined method `[]’ for #<Enumerable… something like this.
But what is this error i couldn’t find. One more thing that i noticed was that it only happens when I am rendering something thorough ajax. This seems like error in Rails.But I was using freezed 2.0.2 version which is fine at local at both development and production mode. Yes right we are not developing on 2.1 as we are using active_scaffold and to avoid the infamous issue between the too we are still on 2.0.2.
So back to my point. I searched a lot but couldn’t find any thing which can help me. Somebody else has got the same issue and filed the ticket here. But noone else could reciprocate the error.
Then suddenly my luck hit and i got a search result in Spanish, which quote the same error i got. I took help of my best buddy Google again & ….Ahhhh ….. i feel so thankful to Blexter for posting this on his blog.
He said that Rails 2.0.2 is released before Ruby 1.8.7 which adds a method chars to class String:. Where Rails defined a method that return a ActiveSupport:: Multibyte: Chars, but if we run into a 1.8.7 we will interpret that to implement the method of a String chars, we return one enumerator so that there already can move around.
The solution he gives is easy either upgrade to 2.1 or remove the method from ruby String class by adding following code to any initializer (eg config / initializers / fixes.rb): or in enviornment.rb(For quick fix).
begin
String.class_eval { remove_method :chars }
rescue NameError
# all Ok
end

Simple na… 🙂
Advertisements