Rake db: migrate not working (Rails 4.0.4)

I have a new application for Rails 4.0.4 / Ruby 2.1.0. The first thing I did was add a gem. When I want to run rake db: migrate, it just does nothing. No error, but no migration.

Could you help me on what to do with this matter? I can not find where the problem is.

Thanks! Petr

+6
source share
3 answers

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

+10
source

I had the same problem as you, Peter, 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). This is what, apparently, should be, but upon further consideration, migration at the end was absent .rb. So it looked like (db / migrate / [timestamp] _devise_create_users). When I added .rb at the end and ran "rake db: migrate", it worked like a charm. I do not know why the rails did not attach ".rb" at the end. Hope this helps.

+7
source

After installing the gem, you should do the following

  • rails generate devise:install

The generator will install an initializer that describes ALL Devise configuration parameters, and you MUST take a look at it. When you're done, you are ready to add Devise to any of your models with a generator.

  • rails generate devise <model>

This is the step that creates migration. For example, if you want to add a device to a user model, you must do

 rails generate devise User 

This way it will generate a migration to add the corresponding columns to the users table

-1
source

All Articles