title: Rails Active Job: perform_later not executing in background
body: <p>I have a lengthy task that needs to run in the background in my Rails 4.2.6 app. Unfortunately, the job is not being sent to the background using Active Job. I've generated a job:</p>
  
  <pre><code>class PhotoProcessorJob &lt; ActiveJob::Base
    queue_as :default
    def perform(*args)
      ::Photo.process_photos
    end
  end
  </code></pre>
  
  <p>which calls a method on my Photo class (stored in config/initializers):</p>
  
  <pre><code>class Photo
    require 'zxing'
    require 'csv'
  
    @tablePath = Dir.glob("#{Rails.root.to_s}/tmp/photo_processing/*.csv")[0]
    @output = "#{Rails.root.to_s}/tmp/photo_data.csv"
  
    def self.getStudentInfo(id)
      CSV.foreach(@tablePath, headers: true) do |row|
        if row["Student ID"] == id
          return row
        else
          next
        end
      end
    end
  
    def self.writeInfoToFile(data, file)
      first_name = data["First Name"]
      last_name = data["Last Name"]
      student_id = data["Student ID"]
      grade = data["Grade"]
      email = data["Email"]
      photo = file.to_s
      CSV.open(@output, "a+") do |csv|
        csv &lt;&lt; [first_name, last_name, student_id, grade, email, photo]
      end
    end
  
    def self.process_photos
      extensions = %w(.jpg .jpeg .png .gif .tif)
      studentInfo = nil
      newfile = false
      if File.exist?(@output)
        outfile = CSV.new(File.read(@output))
        if outfile.count == 0
          newfile = true
        end
      else
        newfile = true
      end
      if newfile
        CSV.open(@output, "wb") do |csv|
          csv &lt;&lt; ["First Name", "Last Name", "Student ID", "Grade", "Email", "Photo"]
        end
      end
      Dir.glob("#{Rails.root.to_s}/tmp/photo_processing/*").each do |file|
        if file.match(/#{extensions.join("|")}/)
          id = ZXing.decode File.new(file)
          unless id.nil?
            studentInfo = getStudentInfo(id)
          else
            writeInfoToFile(studentInfo, file) unless studentInfo.nil?
          end
        end
      end
    end
  
  end
  </code></pre>
  
  <p>and called from a controller:</p>
  
  <pre><code>class ProcessingController &lt; ApplicationController
    def finish
      PhotoProcessorJob.perform_later
    end
  end
  </code></pre>
  
  <p>I'm trying to use the Active Job Inline backend and so do not have any queue libraries installed. The problem is that the "finish" view is delayed while the <code>process_photos</code> method runs rather than it being sent to the background and the view being displayed immediately. This results in a 502 error within Nginx caused by <code>upstream prematurely closed connection</code> presumably because the <code>process_photos</code> task is taking too long to complete.</p>
  
  <p>Have I done something wrong with my Active Job setup? </p>