Cannot run rake db:migrate, relation does not exist

a 夏天 提交于 2019-12-01 08:20:11

The Routes file in Rails uses device_for, which loads the User model, which in turn has acts_as_messagable and loads the Message class. Line #29 in Message class says:

scope :unread, where('reciever_open = false')

The where method is triggering a column lookup, which fails because the migrations haven't run yet! Try one of these two:

Change this to:

scope :unread, where(:reciever_open => false)

Or if that also triggers a column lookup, then say:

scope :unread, lambda { where('reciever_open = false') }

Just trying to check on the obvious here, but have you tried running rake db:drop? Whenever I make changes to my migrations, I need to drop all of my DB tables before I try to create and migrate them.

So the full operation would be rake db:drop db:create db:migrate

Oh, and you can also try to specify the environment (I sometimes need to do that on test environments), e.g. rake RAILS_ENV=test db:drop db:create db:migrate

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