0
我不知道为什么这不是在rails中工作,但它在IRB中工作。设置一个现有的变量到自己的第一个元素
我做这样的事情:
response = response.first
response
是哈希数组。
在irb中,当试图模拟它时,它工作正常。
如:
如:
(rdb:1) response = response.first
NoMethodError Exception: undefined method `first' for nil:NilClass
(rdb:1) response
nil
然后
>> a = [{'a'=>3}]
=> [{"a"=>3}]
>> a = a.first
=> {"a"=>3}
然而,在调试模式下,黄瓜(在我的步骤定义),我做了上述语句时得到这个,response
设置为nil
。
为什么行为不同?
正确的金钱,:) ..我想通了和反应是一个方法在不同的文件中。 D'哦.. – volk