title: Invalid argument @ rb_sysopen in Ruby on Rails application
body: <p>I know this is the common question in this forum, but I tried last nearly 4 hours one by one not working for me. Worked before another method &amp; another resource but not in this method.</p>
  
  <p>Error below:</p>
  
  <p><strong>Invalid argument @ rb_sysopen - <a href="https://example.s3.amazonaws.com/uploads/Data.pdf" rel="nofollow noreferrer">https://example.s3.amazonaws.com/uploads/Data.pdf</a></strong></p>
  
  <p>When I use like below: <strong>Static File</strong></p>
  
  <pre><code>@file = File.open("#{Rails.root}/public/Data.pdf")
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>File.new(@file)
  </code></pre>
  
  <p>That is working but when like below: </p>
  
  <p><strong>Dynamic File</strong></p>
  
  <pre><code>@file = File.open("#{papers.paper.url}") #=&gt; output url: https://example.s3.amazonaws.com/uploads/Data.pdf
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>File.new(@file)
  </code></pre>
  
  <p>That is showing error. I have tried string like <code>w</code> <code>w+</code> <code>r</code> <code>r+</code> etc.</p>
  
  <p>What I'm doing wrong with this code?</p>
  
  <p>Thanks</p>