【问题标题】:Rails - can't make database migration on Heroku for app using Devise authenticationRails - 无法使用 Devise 身份验证在 Heroku 上为应用程序进行数据库迁移
【发布时间】:2012-05-24 03:30:18
【问题描述】:

我的应用程序使用 Devise 身份验证 gem。

当我这样做时

rake db:migrate

在本地,一切都很顺利,但是当我在 Heroku 上执行此操作时:

heroku run rake db:migrate --app myappname

我明白了

rake aborted!
uninitialized constant Devise::Encryptors::Base

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

我不知道会出什么问题。

【问题讨论】:

  • rake db:migrate --trace 说什么?

标签: ruby-on-rails heroku devise database-migration


【解决方案1】:

我遇到了同样的问题,因为我实现了自定义加密器。自 2.1 版以来,devise 自定义加密器已被提取到单独的 gem 中。要使其正常工作,请执行以下操作。

将可设计加密的 gem 添加到您的 Gemfile

gem 'devise-encryptable'

来自 Devise::Encryptable::Encryptors::Base 的子类,而不是 Devise::Encryptors::Base。

# lib/devise/encryptors/md5.rb
require 'digest/md5'

module Devise
  module Encryptable
    module Encryptors
      class Md5 < Base
        def self.digest(password, stretches, salt, pepper)
          str = [password, salt].flatten.compact.join
          Digest::MD5.hexdigest(str)
        end
      end
    end
  end
end

我也更新了设计的how-to page。我希望这能解决你的问题。

【讨论】:

    猜你喜欢
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    • 2014-01-04
    • 1970-01-01
    • 2014-02-25
    • 1970-01-01
    • 2017-11-06
    相关资源
    最近更新 更多