undefined method `fetch_value' for nil:NilClass when using Roo

我们两清 提交于 2019-11-28 13:52:00

It seems you had some leftovers from your non rails practice, as we found in the comments. Notably, the overwritten initialize method, and the attr_accessor for each of the attributes. Removing them (and fixing the DataPoint.new() for the correct format) was all that was needed.

I ran into a similar error also when trying to use Active Record with a legacy database. The problem for me was related to the fact that one of the columns of my database was named 'class,' which caused all sorts of things to fail. I renamed the column in the legacy database and everything worked fine.

Moral of the story- check the column names for any reserved words.

This is the problem encountered yesterday, the reason is I defined a Database field with name class, which is a reserved word for the Ruby language. It caused the conflict.

Douglas Rosa

Remove your def initialize() method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!