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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:57:41+00:00 2026-05-24T20:57:41+00:00

I’m trying to delay the increment on a column ( yest_shareholder_count ) by one

  • 0

I’m trying to delay the increment on a column (yest_shareholder_count) by one day whenever an investment is created in order to keep a record of the number of users that had an investment in a venture one day ago (so I can use this data to produce graphs tracking the number of investors over time).

I figured the simplest way to do this would be to use delayed_job, 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. But the yest_shareholder_count column is not being incremented.

Venture Model:

  def yest_increment
       self.increment!(:yest_shareholder_count)
  end
  handle_asynchronously :yest_increment, :run_at => Proc.new {1.minute.from_now}

Investments Controller:

  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

The straightforward increment happens as it should, but the delayed increment never does.

These are the contents of the “handler” column in the delayed_jobs table, just in case they are useful:

--- !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: []

I’m not sure where the “yest_increment_without_delay” is coming from, or why “args” is blank…

Any help much appreciated.

EDIT: I have “1.minute.from_now” rather than “1.day.from_now” just to test the code.

  • 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-05-24T20:57:42+00:00Added an answer on May 24, 2026 at 8:57 pm

    When you define a method to be handled asynchronously using delayed job, delayed job creates an alias method chain(which I am not very familiar with). It leads to calls original method name handled by delayed job, and when delayed job gets around to it, it calls the original_method_name_without_delay, which is the actual objects method aliased.

    There are no arguments as you didn’t pass any arguments to yest_increment. If you pass any arguments to yest_increment they will be saved along with the job, to be passed on to actual method when delayed job calls it.

    The object in the table is the serialized version of the object, delayed_job stores in db. When job needs to be run, it will create a object by deserializing this and call the method with given arguments on it. As the object is an ActiveRecord object, de-serialization involves, retrieving id from serialized object and finding the object from database.

    As per your actual problem, that it is not working, it is not clear what is not working. Does the delayed job is not getting called or the value is not getting incremented or the delayed_job gets called too soon. If its the last one, changing your code to following might help:

    handle_asynchronously :yest_increment, :run_at => Proc.new {Time.now.beginning_of_day + 1.day}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.