NoMethodError:未定义的方法`存在?&#39; for#<aws :: resources :: collection:0x00000100b690f8>

时间:2016-03-04 19:17:39

标签: ruby-on-rails ruby amazon-web-services rubygems aws-sdk

unless skip_error_checks
  bucket_source = @@s3.bucket(from_bucket)
  bucket_dest = @@s3.bucket(to_bucket)
  old_object = bucket_source.objects(name)
  new_object = bucket_dest.objects(new_name)
  new_exists = new_object.exists?
  old_exists = old_object.exists?
  if new_exists && old_exists
    return error("#{name} in #{from_bucket} and #{new_name} in #{to_bucket} exist.")
  elsif new_exists && !old_exists
    return error("This action has been done already.")
  elsif !old_exists
    return error("#{name} in #{from_bucket} do not exist it may have been permanently deleted.")
  end

我正在使用aws-sdk 2.1.4,即使我按照aws-sdk的文档看到nomethod错误,有没有人有同样的问题

1 个答案:

答案 0 :(得分:1)

自版本2起,exists?方法已为removed

一些方法have been added to only some classes。如果您想添加其他exists?,则解决方案由提供的链接提供:

  

要添加其他#exists?方法,必须将服务员添加到资源类Exists,并且必须在该服务的*.waiters.json文档中定义服务员。