Note that there are some explanatory texts on larger screens.

plurals
  1. POIncrementing using delayed_job
    text
    copied!<p>I'm trying to delay the increment on a column (<code>yest_shareholder_count</code>) by one day whenever an <code>investment</code> is created in order to keep a record of the number of users that had an <code>investment</code> in a <code>venture</code> one day ago (so I can use this data to produce graphs tracking the number of investors over time).</p> <p>I figured the simplest way to do this would be to use <code>delayed_job</code>, but this isn't working. The delayed_job is created in a separate table and, according to the SQLite DB Browser, it is run one day later. <strong>But the yest_shareholder_count column is not being incremented.</strong></p> <p><code>Venture</code> Model:</p> <pre><code> def yest_increment self.increment!(:yest_shareholder_count) end handle_asynchronously :yest_increment, :run_at =&gt; Proc.new {1.minute.from_now} </code></pre> <p><code>Investments</code> Controller:</p> <pre><code> def create @venture = Venture.find(params[:share_id]) @venture_increment= @venture.increment(:shareholder_count) @venture_yest_increment= @venture.yest_increment @investment = current_user.invest!(@venture) if @venture_increment.save and @venture_yest_increment.save respond_to do |format| format.html {redirect_to @venture} end end end </code></pre> <p>The straightforward increment happens as it should, but the delayed increment never does.</p> <p>These are the contents of the "handler" column in the delayed_jobs table, just in case they are useful:</p> <pre><code>--- !ruby/struct:Delayed::PerformableMethod object: !ruby/ActiveRecord:Venture attributes: created_at: 2011-06-21 07:00:12.252808 onemth_shareholder_count: 0 updated_at: 2011-08-09 16:50:36.864354 onewk_shareholder_count: 0 shareholder_count: 4 id: 49 user_id: 40 yest_shareholder_count: 0 method_name: :yest_increment_without_delay args: [] </code></pre> <p>I'm not sure where the "yest_increment_without_delay" is coming from, or why "args" is blank...</p> <p>Any help much appreciated.</p> <p>EDIT: I have "1.minute.from_now" rather than "1.day.from_now" just to test the code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload