设计用户的rails pg db迁移未定义方法“database_authenticatable”

2023-12-26

undefined method database_authenticatable' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition:0xd715388>

迁移是:

class DeviseCreateUsers < ActiveRecord::Migration
  def self.up
    create_table(:users) do |t|
      t.database_authenticatable :null => false
      t.recoverable
      t.rememberable
      t.trackable
      t.timestamps
    end
    add_index :users, :email,                :unique => true
    add_index :users, :reset_password_token, :unique => true
  end
  def self.down
    drop_table :users
  end
end

如果我没记错的话,设计改变了它生成的迁移风格

create_table(:user) do |t|
  t.database_authenticatable
end

to

create_table(:user) do |t|
  ## Database authenticatable
  t.string :email,              :null => false, :default => ""
  t.string :encrypted_password, :null => false, :default => ""
end

2.0版本之后。

更新:看这个wiki https://github.com/plataformatec/devise/wiki/How-To%3a-Upgrade-to-Devise-2.0-migration-schema-style.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

设计用户的rails pg db迁移未定义方法“database_authenticatable” 的相关文章

随机推荐