Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7550731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:17:26+00:00 2026-05-30T10:17:26+00:00

Actually I’m doing something like this : project = Project.find(params[:id]) attachments_list = project.attachments.where{attach_file_size >

  • 0

Actually I’m doing something like this :

project          = Project.find(params[:id])  
attachments_list = project.attachments.where{attach_file_size > 0}
assets_list      = project.assets.where{image_file_size > 0}
#Person.where{(name =~ 'Ernie%') & (salary < 50000) | (name =~ 'Joe%') & (salary > 100000)}
file_name  = project.title.downcase.gsub(' ', '_destroy')
file_name  = "#{file_name}.zip"

temp_file  = Tempfile.new("#{file_name}-#{current_user.id}")
Zip::ZipOutputStream.open(temp_file.path) do |zos|
  attachments_list.each do |file|
    zos.put_next_entry(file.title)
    zos.print IO.read(file.attach.path)
  end
  assets_list.each do |file|
    zos.put_next_entry(file.title)
    zos.print IO.read("#{file.image.path}")
  end
end

send_file temp_file.path, :type => 'application/zip',
                          :disposition => 'attachment',
                          :filename => file_name
temp_file.close

It’s work but the extension is missing on the received files, any idea ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:17:27+00:00Added an answer on May 30, 2026 at 10:17 am

    I finally make a method inside the concerned model to return the file name with the extension

    def title_with_ext
        "#{self.title}#{File.extname(self.image.path)}"
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually I don't know how to find solution to this problem and how to
actually I can not find an exact title for this problem. But I can
Actually, I am trying to find if this product is in a wishlist or
Actually, this question seems to have two parts: How to implement pattern matching? How
Actually, I'm using this way. Do you have a better way? private bool AcceptJson(HttpRequest
Actually what i am trying to build is like a kind of firewall. It
Actually this is my code: echo <pre>; // get current vars $p1 = isset($_GET['p1'])
Actually i'm pretty confused about this terms and how they relate to each other.
Actually I came up with this question, because of an example in one book
Actually this is a classic problem as SO user Victor put it (in another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.