我继承了一个项目,其中 ActiveRecord 模型给了我奇怪的行为。到目前为止,这是唯一一个这样做的模型。
car = Car.first
car.respond_to?(:each) # true
我找不到任何each
定义的方法。Car
我在另一篇文章中读到,您可以找出谁注入了该方法,所以我试了一下:
car.method(:each) # raises "undefined method `each' for class `Car'
我想Car
与draper一起使用,但是因为我的实例的行为类似于 Enumerable,所以 draper 将其视为这样。然而,德雷珀不是问题。
我该怎么做才能弄清楚?