我试图在轨道上运行地理编码器宝石。当我试图获得两个位置之间的距离时,我得到一个错误,说我有一个未定义的局部变量或方法。有谁知道为什么会这样?我尝试用小写的r和大写字母来调用它,但没有骰子。任何帮助表示赞赏。 Image of my terminal
从我在你的图像中看到的,你没有定义restaurant_1或restaurant_3你可以这样做:
@restaurants = Restaurant.first(3)
@restaurants[0].distance_to(@restaurants[2])
我建议你看看这个:
https://guides.rubyonrails.org/active_record_querying.html#first