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

  • Home
  • SEARCH
  • 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 624209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:10:33+00:00 2026-05-13T19:10:33+00:00

Is it acceptable to call ActionText from within ActiveRecord? def last_updated updated_at? ? Updated

  • 0

Is it acceptable to call ActionText from within ActiveRecord?

def last_updated
  updated_at? ? "Updated #{ActionText::time_ago_in_words(updated_at)} ago" : "never updated"
end

Is there an argument against doing something like this? Should this be a helper method?

  • 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-13T19:10:33+00:00Added an answer on May 13, 2026 at 7:10 pm

    Yes. According to strict MVC teachings, it is bad form and belongs in a helper.

    In theory: This particular chunk of functionality is presentation specific, therefore by MVC teachings it belongs in a view helper.

    In practice: It really doesn’t matter. I believe ActionText is parsed when the server/console is loaded. Meaning that the file doesn’t need to be loaded again. Also calling the method directly instead of including ActionText is probably better from the memory management side.

    No body is going to stop you from adding this code to the Model or force you from doing things the Right Way

    Personally I prefer to define these kinds of methods in the model just because I find the syntax of an instance method(model.last_updated) is more aesthetically appealing than that of a helper(last_updated(model)). However the dynamic nature of ruby allows you to do have it both ways. Essentially define instance methods on your model that is only available in views. All it needs is an extra step.

    If you’re really interested in that extra step, it would look like this:

    module ModelHelper 
      def included(base)
        Model.send(:include, ModelInstanceMethods)
      end
    
      module ModelInstanceMethods
        def last_updated
          updated_at? ? "Updated #{ActionText::time_ago_in_words(updated_at)} ago" : "never updated"
        end
      end
    end
    

    Where Model is the class name of the model you want this method to be a part of.

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

Sidebar

Ask A Question

Stats

  • Questions 350k
  • Answers 350k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not 100% sure of the feasibility but to strictly… May 14, 2026 at 7:08 am
  • Editorial Team
    Editorial Team added an answer This is going to be very challenging to do. There's… May 14, 2026 at 7:08 am
  • Editorial Team
    Editorial Team added an answer Here is a simple demo: var lookup = new Dictionary<int,… May 14, 2026 at 7:08 am

Related Questions

I need to implement a web client in a Rails app. The existing web
As far as best practices go is this recommended? I have a comments controller
The general advice is that you should not call GC.Collect from your code, but
I'm trying to make a quick dummy app so I can learn the ins
Hi Is it acceptable to override the Render method when creating a custom web

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.