0

Here is my loop

 subscriptions.each do |s|
     if s.is_active? && s.is_current?
        #do some stuff
     end
  end

subscriptions is an array that has one element. However it does not hit the if statement inside the loop.

When I step through it using rdebug I get this

(rdb:1748) p subscriptions.count
1

I am on ruby version 1.8.7

Am I missing something?

Thank you in advance for your help.

4

2 回答 2

1

检查它是否有效?

subscriptions.each { |s| puts s }

如果上面的代码打印了您的元素,那么您的条件存在一些问题,即下面的代码不正确:

if s.is_active? && s.is_current?
  #do some stuff
end
于 2013-01-02T17:55:56.470 回答
0

问题最终是数据库中某些数据的大小写敏感性。现在一切都很好。奇怪的是,它似乎跳过了障碍,但我确信这是我自己对 ruby​​-debug 工作原理的无知。毕竟我对 ruby​​/rails 开发还比较陌生。谢谢大家!

于 2013-01-02T19:47:43.233 回答