ruby-on-rails – 设计迁移不起作用

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 设计迁移不起作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用Devise创建了一个User模型,每当我使用rake db:migrate时,我都会遇到以下问题:
  1. == DeviseCreateUsers: migrating ==============================================
  2. -- create_table(:users)
  3. rake aborted!
  4. An error has occurred,this and all later migrations canceled:
  5.  
  6. undefined method `database_authenticatable' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x00000103fa1ff0>
  7.  
  8. Tasks: TOP => db:migrate
  9. (See full trace by running task with --trace)@H_403_3@
  10. 我使用–trace函数运行完整的跟踪,但似乎无法弄清楚问题是什么.
    这是迁移文件

  11. class DeviseCreateUsers < ActiveRecord::Migration
  12. def self.up
  13. create_table(:users) do |t|
  14.   t.database_authenticatable :null => false
  15.   t.recoverable
  16.   t.rememberable
  17.   t.trackable
  18.   t.confirmable
  19.   # t.encryptable
  20.   # t.lockable :lock_strategy => :Failed_attempts,:unlock_strategy => :both
  21.   # t.token_authenticatable
  22.   t.timestamps
  23.  end
  24. add_index :users,:email,:unique => true
  25. add_index :users,:reset_password_token,:confirmation_token,:unique => true
  26. # add_index :users,:unlock_token,:authentication_token,:unique => true
  27. end
  28. def self.down
  29.   drop_table :users
  30.   end
  31. end@H_403_3@

解决方法

很高兴听到.
我想官方的答案是重新运行这些步骤:

rails g devise:安装

rails g设计用户

rake db:migrate

rails s //循环你的服务器以防万一……

猜你在找的Ruby相关文章