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

  • Home
  • SEARCH
  • 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 8707281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:49:53+00:00 2026-06-13T03:49:53+00:00

I am uploading a tab-delimited document and processing in the controller. Everything works fine,

  • 0

I am uploading a tab-delimited document and processing in the controller. Everything works fine, but can take some time on a large file. I want to move this to a delay_job, which I have working elsewhere in my app, but as this is in the controller, cannot be called in the same way.

The form calls on the process_file action, which in turn calls on the salesupload action. How should I turn this into a background job?

class SalesController < ApplicationController

  def salesupload(file)
    uploaded_io = file.read
    numrows = "uploaded_io.size"
    FasterCSV.parse(uploaded_io, {:headers => true, :col_sep =>"\t"}).each do |row_data|
        full, upc, _discard, isrc = row_data[26].match(/^([^_]+)(_(.+))?/).to_a
          new_record = AppleSale.new(
              'provider' =>  row_data[0],
              'provider_country' => row_data[1],
              'vendor_identifier' => row_data[2]
          )
      new_record.save
    end
  end

    def process_file
        file = params[:apple_sale][:tsv_file]
        salesupload(file)
    end

end
  • 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-13T03:49:54+00:00Added an answer on June 13, 2026 at 3:49 am

    I found when I had to do this that the method defined in the controller has to be a class method. I can’t remember why this was, I think it had to do with having a more explicit receiver. So what I would do is make the salesupload method a class method, and then just call .delay on it.

    def self.salesupload(files)
      # code
    end
    
    def process_file
      file = params[:apple_sale][:tsv_file]
      SalesController.delay.salesupload(file)
      head :no_content
    end
    

    And you should be good to go! I also made my original method (process_file in this case) called via AJAX, and then I appended the head :no_content so that it returned something without needing a redirect or anything.

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

Sidebar

Related Questions

Uploading an application that works fine on my wamp server but not on the
Uploading a Magento install I have spent a long time building a store with
uploading photos to a wall, i can use the items below, I am using
I am uploading an image to amazon S3 using php through webservice but it
When uploading an excel file I am receiving this error, can anyone help me?
I'm a doof and keep uploading .Rpoj, .Rbuildignore and .gitignore to github. Some of
While uploading multiple image at a time i want to show progress bar which
When uploading file, is that possible to get the create time of the file
Uploading and resizing images of any size works flawlessly on my desktop running development
On uploading my App onto the market today, I saw that it is only

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.