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 8839561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:15:51+00:00 2026-06-14T10:15:51+00:00

I want to send the file file.txt from my Rails controller using send_file ,

  • 0

I want to send the file file.txt from my Rails controller using send_file, and then delete the folder containing it.

send_file("#{Rails.root}/public/folder/file.txt")
system("rm -rf #{Rails.root}/public/folder")

When I tried this, file.txt was correctly sent, file.txt was correctly deleted, but somehow folder was not deleted.

How can I make it delete folder?

  • 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-06-14T10:15:53+00:00Added an answer on June 14, 2026 at 10:15 am

    Try to delete the folder directly with the native ruby method instead of a system command:

    require 'fileutils'
    FileUtils.remove_dir "#{Rails.root}/public/folder", true
    

    http://www.ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_dir

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to read a txt file from clients and then send it to
I want to send more than one image file from client to server for
Hi I want to send attachment with mail using javaMailAPI. my code is: public
I'm working on a piece of homework and I want to send a FILE
I want to send a opened file descriptor between two different programs. So I
I want to send a xml file to my wcf service , how can
I want to program an application to send a file with sockets: Here my
I have a text file that I want to send over the network, this
I want to use the TcpClient and TcpListener to send an mp3 file over
I want to create this parameter file so that I can send it to

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.