title: Stripping a string to build a new S3 path
body: <p>In my project I am assigning individual UUIDs to every upload that gets moved between two folders in my S3 Bucket, for the purposes of individualising their links later on.</p>
  <p>However, while attempting to format the Object Key as displayed in the method below, all the code below<br />
  <code>parts = old_key.split('/')</code> greys out/ no longer functions, indicating a Syntax error that I can't see.</p>
  <pre><code>def move_and_rename(target_folder, prefix_generator: nil)
      prefix_generator ||= -&gt; { SecureRandom.uuid }
        s3_objects.each do |obj|
          prefix = prefix_generator.call
          old_key = obj.key
          parts = old_key.split('/')
          new_last_part = &quot;#{prefix}-#{parts.last}”
          new_key = (parts[0..-2] + [new_last_part]).join('/')
          new_key = s3_folder ? obj.key.sub(s3_folder, target_folder) : (parts[0..-2] + [new_last_part]).join('/')
  
  
          obj.move_to(bucket: bucket_name, key: new_key)
        yield(old_key: old_key, new_key: new_key, obj: obj, prefix: prefix) if block_given?
      end
      self
    end
  </code></pre>
  <p>Or perhaps I have this structured completely wrong within the method? Any pointers would be appreciated.</p>