rake db:migrate doesn't work (Rails 4.0.4)

。_饼干妹妹 提交于 2019-12-05 08:05:50

OK, so the problem was that Devise generator generated ".txt" file with migration instead of ".rb" file. Strange, but changing extension solved it.

I had the same problem as you Petr and I think I found out why. For some reason when I ran 'rails g devise User', it created a migration (db/migrate/[timestamp]_devise_create_users.rb). That's what it suppose to be, but upon further examination, the migration was missing the '.rb' at the end. So it looked like (db/migrate/[timestamp]_devise_create_users). When I added the .rb at the end, and ran 'rake db:migrate' it worked like a charm. I don't know why rails didn't attach the '.rb' at the end. Hope that helps.

After you install devise gem, you have to do the following

  1. rails generate devise:install

The generator will install an initializer which describes ALL Devise's configuration options and you MUST take a look at it. When you are done, you are ready to add Devise to any of your models using the generator

  1. rails generate devise <model>

This is the step that generates the migration. For eg, If you want to add devise to user model, you should do

rails generate devise User

So it will generate a migration to add devise related columns to users table

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