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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:31:03+00:00 2026-06-09T17:31:03+00:00

I got datetime filds order_confirmed_at and completion_confirmed_at class CoolModel < ActiveRecord::Base attr_accessible :order_confirmed, completion_confirmed

  • 0

I got datetime filds order_confirmed_at and completion_confirmed_at

class CoolModel < ActiveRecord::Base
  attr_accessible :order_confirmed, completion_confirmed

  def order_confirmed
    order_confirmed_at.present?
  end

  def order_confirmed=(state)
    if state and order_confirmed_at.blank?
      self.order_confirmed_at = Time.now
    end
    order_confirmed_at.present?
  end

  def completion_confirmed
    completion_confirmed_at.present?
  end

  def completion_confirmed=(state)
    if state and completion_confirmed_at.blank?
      self.completion_confirmed_at = Time.now
    end
    completion_confirmed_at.present?
  end
end

…so in my view I can just check checkbox that order was confirmed and completed

Thing is: not only this is duplication, but this stuff obviously looks pretty standard. So in matter saving me time writing gem: is there rails gem/engine doing this (or maybe part of Rails I’m not aware of) ??

class CoolModel < ActiveRecord::Base
  #something like this 
  acts_even_coller_on :order_confirmed_at, :completion_confirmed_at
end
  • 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-09T17:31:04+00:00Added an answer on June 9, 2026 at 5:31 pm

    You could just override the setter method.

    def confirmed_at=(value)
      super value == "true" ? confirmed_at || Time.now : nil
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a base Class ScenBase and a derived class ScenC. I have a
How could we handle null for a datetime field (got from SQL Server) in
I've got something like this DateTime.Now.ToString(dd.MM.yy); In my code, And I need to add
I' ve got a short question. How could I insert values contain a datetime
while doing LINQ I got this Error. Cannot implicitly convert type 'System.DateTime?' to 'System.DateTime'.
I've got a record set that consists of a start and end time in
I've got this model: class Visit(models.Model): timestamp = models.DateTimeField(editable=False) ip_address = models.IPAddressField(editable=False) If a
I have got 2 fields in my db(sql server 2008) namely updateDate[Datetime] & calldate[datetime].
I've got a single datatable that contains the fields: TransactionID (int), TransactionDate (DateTime) AdjustedValue
I have got a Sales table which has fields like upgrade[yes/no] date upgraded[datetime] user[username]

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.