首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误module_inheritable_attributes.rb中的值为零

错误module_inheritable_attributes.rb中的值为零
EN

Stack Overflow用户
提问于 2020-02-05 00:46:20
回答 1查看 54关注 0票数 0

我有以下脚本:

代码语言:javascript
复制
require 'httparty'
require 'aws-sdk-s3'

include HTTParty

Aws.config.update({
  region: 'us-east-1',
  credentials: Aws::Credentials.new('...', '...')
})

client = Aws::S3::Resource.new
movies = self.class.get("#{HOST}/movies")

当我运行它时,会遇到以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
        10: from script.rb:33:in `<main>'
         9: from script.rb:33:in `new'
         8: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-athena-1.22.0/lib/aws-sdk-athena/resource.rb:14:in `initialize'
         7: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:99:in `new'
         6: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-athena-1.22.0/lib/aws-sdk-athena/client.rb:262:in `initialize'
         5: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:19:in `initialize'
         4: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/base.rb:62:in `build_config'
         3: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:149:in `build!'
         2: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:158:in `empty_struct'
         1: from /Users/me/.rvm/gems/ruby-2.6.5/gems/aws-sdk-core-3.78.0/lib/seahorse/client/configuration.rb:158:in `new'
/Users/me/.rvm/gems/ruby-2.6.5/gems/httparty-0.17.1/lib/httparty/module_inheritable_attributes.rb:42:in `inherited': undefined method `each' for nil:NilClass (NoMethodError)

在阅读了AWS的文档和教程之后,我仍然找不到问题。有什么不对的?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-05 00:46:20

我发现问题是线include HTTParty。我在S3客户端之前声明了这一行,它现在起作用了:

代码语言:javascript
复制
require 'httparty'
require 'aws-sdk-s3'

Aws.config.update({
  region: 'us-east-1',
  credentials: Aws::Credentials.new('...', '...')
})
client = Aws::S3::Resource.new

include HTTParty

movies = self.class.get("#{HOST}/movies")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60067552

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档