Rails 4: schema.db shows “Could not dump table ”events“ because of following NoMethodError# undefined method `[]' for nil:NilClass”

本秂侑毒 提交于 2019-11-29 23:35:08

I think your last migration is wrong. I would change it to this:

class AddEventRefToPressBlurbs < ActiveRecord::Migration
  def change
    add_reference :press_blurb, :event
  end
end

Unfortunately, your database is likely in a wonky state because it has an invalid column type (i.e. there is no 'reference' column type, but sqlite made it anyway). Hopefully, it's just a development database so you can just delete it and start fresh.

Just in case this helps someone. I was doing this on a sqlite dev db, and as mentioned above, it was likely in a wonky state from all my experimental migrations. By deleting the sqlite file, recreating and running all the migrations, it is now fine.

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