在 omniauth 更新后 Rails 服务器停止运行中断设计

问题描述

我按照从分支到主(设计)的拉取请求,但我仍然遇到错误,我无法再将 api 部署到服务器

我也尝试了这个问题中提供的解决方案,但没有成功:

Latest omniauth-facebook gem breaks devise

错误

/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/devise-4.7.3/lib/devise/omniauth.rb:12:in `<top (required)>': You are using an old OmniAuth version,please ensure you have 1.0.0.pr2 version or later installed. (RuntimeError)

本地主机上的错误是一样的

Ruby 版本:2.5.1p57

导轨 (5.1.7)

设计(4.7.3)

omniauth (2.0.1)

omniauth-facebook (8.0.0)

omniauth-oauth2 (1.7.1)

解决方法

我认为 this commit 解决了您所看到的问题,遗憾的是它不会通过 bundle update 自动拉入您的项目,直到设计颠簸他们的版本。

所以我认为您可以在 Gemfile 中使用 gem 'devise',github: 'heartcombo/devise' 修复此问题(您可能需要先卸载原始版本)

您可以通过使用 bundle show devise 来验证新 gem 的位置,转到 lib/devise/omniauth.rb,并确保它打开时显示以下内容:

# PATH_TO_DEVISE_GEM/lib/devise/omniauth.rb

# frozen_string_literal: true

begin
  gem "omniauth",">= 1.0.0"

  require "omniauth"
rescue LoadError
  warn "Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile."
  raise
end

当我昨天遇到这个完全相同的问题时,我的版本有以下内容,这就是为什么它对我来说是崩溃的:

# PATH_TO_OLD_DEVISE_GEM/lib/devise/omniauth.rb

[...]
unless OmniAuth::VERSION =~ /^1\./  if Gem::Version.new(OmniAuth::VERSION) < Gem::Version.new('1.0.0')
  raise "You are using an old OmniAuth version,please ensure you have 1.0.0.pr2 version or later installed."     raise "You are using an old OmniAuth version,please ensure you have 1.0.0 version or later installed."
end
[...]
,

devise 更新到最新版本(当前为 4.8.0)应该可以解决问题。我可以确认在我的情况下确实如此。

此处有更多信息:https://github.com/heartcombo/devise/commit/1d138dd40cdc291a427b89027d16a869818a5c19#commitcomment-50168476