title: Download all attachments in a model RAILS
body: <p>I am using <code>rails4</code> with <code>paperclip</code> and <code>rails_admin</code> gems and I am trying to make a link which when clicked will download all the attachments from the submission table.</p>
  
  <p>Here is my code</p>
  
  <p><code>rails_admin/main/index.html.haml</code></p>
  
  <pre><code>- if @abstract_model.table_name == "submissions"
          = link_to "Download all", '/downloadAttachments'
  </code></pre>
  
  <p><code>submission_controller.rb</code></p>
  
  <pre><code># Download zip file of all submission
    def download
      @submissions = Submission.all
  
      file = @submissions[0].file.url(:original, false) #folder to save the archive to
  
      Zip::ZipFile.open(file, create=nil) do |zipfile|
        @submissions.each do |filename|
         zipfile.add(filename.file_file_name, filename.file.url(:original, false))
        end
      end
    end
  </code></pre>
  
  <p><code>routes.rb</code></p>
  
  <pre><code>get '/downloadAttachments' =&gt; 'submissions#download'
  </code></pre>
  
  <p>When I click the link though, I get a message <code>Cannot find submission with id downloadAll</code>. From my experience with rails, that method should get called and create the downloadable zip for me. Question: what is wrong with this def and how can I get that zip downloaded?</p>
  
  <p>[EDIT]</p>
  
  <p>This code seems to work, but it's getting a:</p>
  
  <pre><code>File /files/submissions/files/45/original/file.pdf not found
  </code></pre>
  
  <p>But I can confirm that file definitely exists in my public folder</p>