Reputation: 275
I have a new app on Rails 4.0.4 / Ruby 2.1.0. The first thing I did was adding Devise gem. When I want to run rake db:migrate, it just does nothing. No error, but the migration isn't executed.
Could you please help me what to do with this case? I can't find where is the problem.
Thank You! Petr
Upvotes: 6
Views: 2312
Reputation: 83
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.
Upvotes: 7
Reputation: 275
OK, so the problem was that Devise generator generated ".txt" file with migration instead of ".rb" file. Strange, but changing extension solved it.
Upvotes: 10
Reputation: 29349
After you install devise gem, you have to do the following
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
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
Upvotes: 0