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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:27:23+00:00 2026-06-04T05:27:23+00:00

I have a (cut-down) Model which looks like this: class MyModel < ActiveRecord::Base def

  • 0

I have a (cut-down) Model which looks like this:

class MyModel < ActiveRecord::Base
    def self.update_status
        event_time = time_ago_in_words 30.minutes.from_now
        Twitter.update("Event is starting in #{event_time}")
    end
end

As expected, I am getting a NoMethodError exception due to trying to use a method ‘time_ago_in_words’ from DateHelper. How should I accomplish this, and maybe more importantly, am I going about this the correct way?

  • 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-04T05:27:24+00:00Added an answer on June 4, 2026 at 5:27 am
    1. extend ActionView::Helpers::DateHelper in your model
    2. Change 30.mins.from_now to 30.minutes.from_now

    I just tried it myself and have no problem doing the following:

    class MyModel < ActiveRecord::Base
      extend ActionView::Helpers::DateHelper
    
      def self.update_status
        event_time = time_ago_in_words(30.minutes.from_now)
        Twitter.update("Event is starting in #{event_time}")
      end
    end
    

    You have to use extend instead of include. See this article for an explanation.

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

Sidebar

Related Questions

I have the following basic classes (cut down for this question): public class Parent
I have the following (cut-down) class definition, and it has compilation errors. #include <iostream>
I have an [HttpPost] action method signature like this: [HttpPost] public ActionResult Edit(ExistingPostViewModel model)
Given the following models (cut down for understanding): class Venue(models.Model): name = models.CharField(unique=True) class
This is what I have currently (cut down a little): SELECT *, item_prices.price AS
I have a large sprite library and I'd like to cut GPU memory requirements.
Have added the following code to my SQL query: (Note cut down version) DECLARE
I am coding a big website but I have cut down my problem into
I have a page that will list news articles. To cut down on the
I have a method which basically looks at a variable and if its bool

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.