Rails 奇怪的错误 =>索引错误:字符串不匹配 [英] Rails strange error => IndexError: string not matched

查看:57
本文介绍了Rails 奇怪的错误 =>索引错误:字符串不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了一个非常奇怪的消息错误.我认为它不是来自 Ruby 而是来自 unix 系统.

I've got a very strange message error. I think it's not coming from Ruby but from the unix system.

所以,我有以下测试文件:

So, I have the following test file:

require File.dirname(__FILE__) + '/../test_helper' 

class CatTest < ActiveSupport::TestCase
    def test_truth
    assert true
   end
end

因此,Fixtures 目录中的 YAML 文件没有任何内容.

So, nothing coming from YAML files in the Fixtures directory.

当我使用以下命令运行上面的测试时:

When I run the test above with the command:

$ ruby ./test/unit/cat_test.rb

我得到了非常奇怪的结果:

I get the very strange result:

Loaded suite ./test/unit/cat_test
Started
E
Finished in 0.011252 seconds.

  1) Error:
test_truth(CatTest):
IndexError: string not matched


1 tests, 0 assertions, 0 failures, 1 errors

我找不到错误的含义

IndexError: string not matched

但最奇怪的是,昨天,它奏效了!

But the most strange is that yesterday, It worked!

非常感谢您的帮助.

问候

(我在 Ubuntu 9.04 下工作)

(I'm working under Ubuntu 9.04)

推荐答案

例如,当您错误地尝试将字符串变量作为 Hash 访问时,就会发生这种情况.

This happens, for example, when you try to access a string variable as a Hash by mistake.

s = "a string"
s["position"] = "an other string"

IndexError: string not matched
    from (irb):5:in `[]='
    from (irb):5

附加信息

这篇关于Rails 奇怪的错误 =>索引错误:字符串不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆