尽管表中存在列,Rails 仍没有获取模型属性
== AddIpToTutorials: migrating ===============================================
-- add_column(:tutorials, :ip_address, :string)
-> 0.0022s
== AddIpToTutorials: migrated (0.0022s) ======================================
>> t = Tutorial.new
..
>> t.ip_address
NoMethodError: undefined method `ip_address' for #<Tutorial:0x2b3b35f5a690>
...什么给了? >______>
== AddIpToTutorials: migrating ===============================================
-- add_column(:tutorials, :ip_address, :string)
-> 0.0022s
== AddIpToTutorials: migrated (0.0022s) ======================================
>> t = Tutorial.new
..
>> t.ip_address
NoMethodError: undefined method `ip_address' for #<Tutorial:0x2b3b35f5a690>
... What gives? >______>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最近遇到了完全相同的问题,我不建议进行单独的迁移,而是建议运行命令:
heroku restart
运行上述命令后,heroku 接受了更改,我的应用程序按预期工作。在经历回滚迁移、删除迁移,然后创建新迁移的痛苦之前,请先尝试此操作。
I recently ran into the exact same problem, and instead of making a separate migration I would instead suggest running the command:
heroku restart
After running the above command heroku picked up the changes and my app worked as expected. Try this before going through the pain of rolling back a migration, deleting it, and then creating a new one.
最终进行了单独的迁移并再次做了同样的事情。
很糟糕,但它有效......
Ended up making a seperate migration and doing the same thing again.
Crumby, but it works...