title: Rails how to reload view after job status is completed?
body: <p>I am working on a test project where someone enters a Url into a form and I use an Active Job to retrieve the open graph protocol preview image, and then I want to reload the page using javascript to show the image once the job is done running.</p>
  <p>I have everything working except the reload:</p>
  <p>Controller:</p>
  <pre class="lang-rb prettyprint-override"><code>def open_graph_preview
    @new_preview = Preview.new
    @preview = Preview.last
    # sends newly created Preview to Job
    @job = FindOpenGraphImageJob.perform_later(@preview)
    # begins status check on currently running Job
    @job_status = ActiveJobStatus.fetch(@job.job_id)
  end
  </code></pre>
  <p>Job:</p>
  <pre class="lang-rb prettyprint-override"><code>def perform(preview)
    # Uses Faraday to get all info on the given URL
    response = Faraday.get(preview.url)
    # Uses OGP gem to parse the meta data from Faraday response
    open_graph = OGP::OpenGraph.new(response.body)
  
    @preview = Preview.find(preview.id)
    # Updates the image_url with the open graph image url
    @preview.update_attribute :image_url, open_graph.image.url
  end
  </code></pre>
  <p>View:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;h1&gt;Open Graph Protocol Preview&lt;/h1&gt;
  
  &lt;div class=&quot;d-flex justify-content-center&quot;&gt;
    &lt;%= form_with(model: @new_preview, local: true) do |form| %&gt;
  
      &lt;div class=&quot;field form-group&quot;&gt;
        &lt;%= form.label :url %&gt;
        &lt;%= form.text_field :url, class: 'form-control' %&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;actions form-group&quot;&gt;
        &lt;%= form.submit %&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  &lt;/div&gt;
  
  &lt;div class=&quot;d-flex justify-content-center&quot; style=&quot;padding:50px;&quot;&gt;
    &lt;img src=&quot;&lt;%= @preview.image_url %&gt;&quot;&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Could someone please help me figure out how to use javascript to check the <code>@job_status</code> in the controller, and reload the page when <code>@job_status.completed?</code>?</p>