设计用户的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” 的相关文章

  • Postgres < 9.0 的 DO 块相当于什么

    Postgres 8 4 8 相当于什么 DO BEGIN IF NOT EXISTS THEN EXECUTE END IF END create function f returns void as BEGIN IF NOT EXIST
  • Ruby on Rails:如何使用 TCP 套接字连接 GPS 设备

    ruby 2 3 0p0 2015 12 25 修订版 53290 x86 64 linux 轨道 4 2 4 我正在使用 cloud9 IDE 和 webrick 服务器 我的项目是实时跟踪GPS 我想使用TCP连接与GPS跟踪设备进行通
  • PostgreSQL - 根据另一个单元格值设置默认单元格值

    如果我有一个专栏说column a任何给定值 我想要另一列column b有一个default value根据 的值column a 换句话说 if column a peter then column b default value do
  • “rmagick”gem 安装问题

    我在尝试在 centos 上安装 rmagick gem 时遇到问题 以下是我得到的输出 谁能帮我识别一下我缺少什么包裹 我已经安装了所有提到的另一个堆栈溢出线程 RMagick安装错误 https stackoverflow com qu
  • 我在 Rails 中使用了保留字吗?

    这是我的模型 class Record lt ActiveRecord Base belongs to user belongs to directory end class Directory lt ActiveRecord Base h
  • REXML - 如何提取单个元素

    我正在用 ruby 编写一些验收测试 其中涉及断言响应 XML 中值的存在 我的 XML 是这样的
  • Rails:named_scope、lambda 和块

    我认为以下两个是等效的 named scope admin lambda company id conditions gt company id company id named scope admin lambda do company
  • 在 Rails 3 中渲染 Markdown 文本

    我想将 markdown 转换为 html 在我看来我有markdown some text variable 但我得到了错误undefined method markdown I added require BlueCoth 到envir
  • rvm gem 安装错误?

    我正在摆弄 ruby gems 和 rvm 它工作得很好 但现在当我尝试安装 gem 时出现错误 gem install Rails错误 同时 执行 gem Errno EACCES 权限被拒绝 Users da rvm gems ruby
  • 使用 rspec 测试嵌套路由

    我正在尝试使用 rspec 测试路由 以下给出了 预期块返回真值 的错误 我不确定我错过了什么 通过浏览器我可以发布到这个网址并且成功 有任何想法吗 谢谢 Routes resources forum topics do resources
  • Django 中从 sqlite 迁移到 postgresql

    我想迁移自sqlite to PostgreSQL db 我安装了 postgresql 并在其 shell 上创建数据库 然后配置我的 django 设置如下 default ENGINE django db backends postg
  • Bundle 说 gem 丢失了 - 但事实并非如此?

    背景 我正在维护contentRuby On Rails 站点 但我确实没有 Rails 的经验 当尝试运行 Rails 服务器时 rails s我明白了 在任何来源中均找不到 activesupport 3 2 0 Run bundle
  • java -postgresql 最后插入的 id 插入时未获取

    我有一个插入功能postgresql如下 CREATE OR REPLACE FUNCTION insert orderhead order id integer order dt text customer id integer rout
  • 我无法让 ruby​​ 开发工具包适用于 Windows XP

    所以 我一生都无法让它正常工作 我的最终目标是安装 dbd odbc gem 并使其正常工作 从我读过的多篇文章来看 我需要安装ODBC 绑定 http www ch werner de rubyodbc 对于 ruby 以及 dbd od
  • 在 Ruby 中创建一个空文件:相当于“touch”?

    创建一个的最佳方式是什么emptyRuby 中的文件 类似于 Unix 命令的东西 touch https en wikipedia org wiki Touch 28Unix 29 touch file txt FileUtils tou
  • ruby从1.8.7升级到1.9.2(使用Rails 3.1.1)后本地服务器错误

    我刚刚安装了rvm并使用rvm将ruby从1 8 7升级到1 9 2 我在我的应用程序上运行了捆绑安装 它重新安装了我的 gems 当我在本地运行 Rails 服务器并将浏览器导航到 localhost 3000 时 服务器日志中显示以下错
  • Rails 4 使用 ajax、jquery、:remote => true 和 respond_to 渲染部分

    使用 AJAX 动态渲染页面以响应提交的表单似乎很常见 其他类似的问题都没有集中于如何以一般方式做到这一点 我能找到的关于这个主题的最好的博客文章在这里 http www gotealeaf com blog the detailed gu
  • Postgres JSON 数据类型 Rails 查询

    我正在使用 Postgres 的 json 数据类型 但想要使用嵌套在 json 中的数据进行查询 排序 我想在 json 数据类型上使用 where 进行订购或查询 例如 我想查询关注者数量 gt 500 的用户 或者我想按关注者或关注数
  • 红宝石接球和效率

    catch在 Ruby 中意味着跳出深度嵌套的代码 在 Java 中 例如用Java也可以达到同样的效果try catch用于处理异常 但它被认为是糟糕的解决方案 而且效率非常低 在 Ruby 中 我们有处理异常的方法begin raise
  • 本地 Postgres 实例和 Azure Cloud Postgres 实例之间的实时同步

    我需要在本地 postgresql 实例与云 postgresql 实例之间设置实时同步过程 请让我知道我可以通过哪些选项来实现它 我是否必须使用任何特定工具或者可以通过复制进行管理 请指教 使用 PgPool http www pgpoo

随机推荐