title: Ruby on Rails and AWS S3 Expiring Download Link
body: <p>I am new to coding and I hope I explain this question correctly. Like most people I am starting my journey with Ruby on Rails.</p>
  
  <p>I am trying to request a url from AWS S3 to pass on to the client browser that expires after 20 minutes. I have installed the aws-sdk gem and ran bundle install etc. </p>
  
  <p>I have a welcome controller and an index view. I have the following code in my controller:</p>
  
  <pre><code>  class WelcomeController &lt; ApplicationController
  
    def index
    end
  
    def doc_download
  
      require 'aws-sdk'
  
      s3 = Aws::S3::Client.new(
          access_key_id: 'mykey',
          secret_access_key: 'mykey'
      )
  
      aws_resource = Aws::S3::Resource::new
      aws_resource.bucket('mynewapp.herokuapp.com').object('1.jpg').presigned_url(:get, expires_in: 20.minutes)
  
      @download = doc_download
  
    end
  
  end
  </code></pre>
  
  <p>Then this in my view</p>
  
  <pre><code>&lt;p&gt;&lt;%= link_to 'Download', @download %&gt;&lt;/p&gt;
  </code></pre>
  
  <p>But nothing is happening, the page just refreshes when I click on the 'Download' link.</p>
  
  <p>Any help greatly appreciated, spent a couple of days trying to figure it out from many of the different posts that have attempted to complete this.</p>