未定义的方法“omniauth”对于 Devise:模块(devise、omniauth、heroku、rails 3.0.3)

发布于 2024-12-09 08:01:46 字数 4070 浏览 0 评论 0 原文

我有一个在本地使用亚马逊产品广告 API 的应用程序,没有任何问题。为了将其推送到 Heroku,我必须更改我使用的 aws gem 的版本,以使其与 Heroku 一起使用(“treyconnell-ruby-aaws”v0.8.3),并且该版本将我限制为 Rails 3.0.3 和设计 v1.1.8 宝石。

当我降级宝石和“捆绑更新”时,本地出现了一些情况,猜测omniauth和devise开始战斗。服务器无法启动并出现以下错误日志。

我尝试了加载omniauth gem、oa-auth、需要omniauth/oauth等的许多不同配置,仍然是相同的错误。这里可能有什么问题?

附言。我现在必须使用这个 aws gem。

/Users/eerdogan/Sites/myApp/config/initializers/devise.rb:17: undefined method `omniauth' for Devise:Module (NoMethodError)
    from /Library/Ruby/Gems/1.8/gems/devise-1.1.8/lib/devise.rb:183:in `setup'
    from /Users/eerdogan/Sites/myApp/config/initializers/devise.rb:3
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:201
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:200:in `each'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:200
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
    from /Users/eerdogan/Sites/myApp/config/environment.rb:5
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /Users/eerdogan/Sites/myApp/config.ru:3
    from /Library/Ruby/Gems/1.8/gems/rack-1.2.4/lib/rack/builder.rb:46:in `instance_eval'
    from /Library/Ruby/Gems/1.8/gems/rack-1.2.4/lib/rack/builder.rb:46:in `initialize'
    from /Users/eerdogan/Sites/myApp/config.ru:1:in `new'
    from /Users/eerdogan/Sites/myApp/config.ru:1

编辑:这是 devise.rb 文件:

# 使用此钩子来配置 devise mailer、warden 钩子等。第一个
# 四个配置值也可以直接在您的模型中设置。
Devise.setup 执行 |config|
  config.mailer_sender = "[电子邮件受保护]"
  需要 'devise/orm/active_record'
  config.omniauth :facebook,“1****************”,“3**************************** *****”
  config.case_insensitive_keys = [ :email ]
  配置.拉伸 = 10
  config.use_salt_as_remember_token = true
  config.reset_password_within = 2.小时
结尾

I have an app that uses Amazon Product Advertising API at local with no issues. In order to push it to Heroku, I have to change the version of the aws gem I use to make it work with Heroku ("treyconnell-ruby-aaws" v0.8.3) and that version limits me to Rails 3.0.3 and to devise v1.1.8 gems.

When I downgrade gems and 'bundle update', something breaks even at local, guessing omniauth and devise start fighting. The server fail to starts with the following error log.

I tried many different configurations of loading omniauth gem, oa-auth, requiring omniauth/oauth etc, still the same error. What might be the issue here?

PS. I have to use this aws gem for now.

/Users/eerdogan/Sites/myApp/config/initializers/devise.rb:17: undefined method `omniauth' for Devise:Module (NoMethodError)
    from /Library/Ruby/Gems/1.8/gems/devise-1.1.8/lib/devise.rb:183:in `setup'
    from /Users/eerdogan/Sites/myApp/config/initializers/devise.rb:3
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:201
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:200:in `each'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:200
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
    from /Users/eerdogan/Sites/myApp/config/environment.rb:5
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /Users/eerdogan/Sites/myApp/config.ru:3
    from /Library/Ruby/Gems/1.8/gems/rack-1.2.4/lib/rack/builder.rb:46:in `instance_eval'
    from /Library/Ruby/Gems/1.8/gems/rack-1.2.4/lib/rack/builder.rb:46:in `initialize'
    from /Users/eerdogan/Sites/myApp/config.ru:1:in `new'
    from /Users/eerdogan/Sites/myApp/config.ru:1

Edit: here is the devise.rb file:

# Use this hook to configure devise mailer, warden hooks and so forth. The first
# four configuration values can also be set straight in your models.
Devise.setup do |config|
  config.mailer_sender = "[email protected]"
  require 'devise/orm/active_record'
  config.omniauth :facebook, "1*************", "3******************************"
  config.case_insensitive_keys = [ :email ]
  config.stretches = 10
  config.use_salt_as_remember_token = true
  config.reset_password_within = 2.hours
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

破晓 2024-12-16 08:01:46

我认为 devise.rb 中的 config.facebook 行让您感到悲伤。

我查看了我的 devise.rb,还有另一个名为 omniauth.rb 的文件。

(1) 我的 devise.rb 没有 config.facebook 行。尝试删除它,看看它是否有效。

(2) 我有一个名为 omniauth.rb 的文件,与 devise.rb 位于同一目录中。我将其粘贴在下面:

require 'openid/store/filesystem'

Rails.application.config.middleware.use OmniAuth::Builder do

  case Rails.env
  when "development"
    provider :facebook, 'XXX', 'XXXX' , {:scope => 'manage_pages,publish_stream,offline_access,email'}

  when "production"
    provider :facebook, 'XXX', 'XXXX', {:scope => 'manage_pages,publish_stream,offline_access,email', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}  
    end
end

看看这是否适合您。 :)

I think the config.facebook line in devise.rb is causing you the grief.

I took a look at my devise.rb and I also have another file called omniauth.rb.

(1) My devise.rb does not have the config.facebook line. Try removing that and see if it works.

(2) I have a file called omniauth.rb, located in the same directory as devise.rb. I'm pasting it below:

require 'openid/store/filesystem'

Rails.application.config.middleware.use OmniAuth::Builder do

  case Rails.env
  when "development"
    provider :facebook, 'XXX', 'XXXX' , {:scope => 'manage_pages,publish_stream,offline_access,email'}

  when "production"
    provider :facebook, 'XXX', 'XXXX', {:scope => 'manage_pages,publish_stream,offline_access,email', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}  
    end
end

See if this works out for you. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文