未定义的方法“to_sym”对于 db:auto:migrate 期间的 nil:NilClass
我试图在我的系统中运行 db:auto:migrate ,每当它到达使用日期类型的列时,它就会不断抛出 nil:NilClass 的未定义方法“to_sym”。如果我将字段更改为日期时间并运行迁移,它将将该字段更改为没有错误的日期。是什么导致了这个问题。每次我想运行迁移时,我都必须不断更改字段类型。
我使用日期类型而不是日期时间的原因是因为我试图输出日期,而 Rails 不断调整我的时区的数据,这会给出错误的数据。
谢谢。
乔什
I'm trying to run a db:auto:migrate in my system and it keep throwing the undefined method `to_sym' for nil:NilClass whenever it gets to a column that uses a type of date. If I change the field to a datetime and run the migrate, it will change the field to a date with no errors. What is causing this problem. I have to keep changing the field type every time I want to run my migration.
The reason I'm using the date type instead of the datetime is because I am trying to output the date and Rails keeps adjusting the data for my time zone, which is giving out bad data.
Thank you.
Josh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您错误地命名了列,并且以某种方式生成了 sql 表。我现在正试图解决这个问题。这种情况以前发生过,我只是重建了桌子。
例如,您可能将整数拼写为 integre,这会搞乱一切。无论如何,这就是我所做的。
This is because you named a column wrong and somehow the sql table got generated. I trying to get this fixed right now. This has happened before and I just rebuild the table.
For example, you might have spelled integer as integre and that messes up everything. That is what I did anyways.