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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:03:21+00:00 2026-05-21T05:03:21+00:00

I have an app with categories ‘Active’, ‘Waitlist’, and ‘Terminated’. These are in the

  • 0

I have an app with categories ‘Active’, ‘Waitlist’, and ‘Terminated’. These are in the view as a select box.

When the user selects ‘Terminated’ I want to put the current date into a datetime attribute (in the same model).

What’s the best way to do this? I tried this, but it didn’t work, and I’m not sure it’s the right place to do it:

[in the controller]

def update
  @household = Household.find(params[:id])
  if @household.status.eql? 'Terminated'
      @household.terminated = Date.yesterday()
  end
  if @household.update_attributes(params[:household])
    ....
  end
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-05-21T05:03:22+00:00Added an answer on May 21, 2026 at 5:03 am

    Use after_update callback in your model:

    class Household
    ...
    after_update :update_terminated_date
    
    def update_terminated_date
        return unless status == 'Terminated'
        self.terminated = Date.today() # maybe better Time.now?
        self.save!
    end
    

    EDIT:
    Maybe better idea is to just get rid of status column and set terminated to date when it’s really terminated and to null when it’s not?

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

Sidebar

Related Questions

I have a categories table view controller. In my app, categories can have subcategories.
I have an app where I want unlimited categories and sub-categories and would only
My app has 3 categories of buttons, I want to have a tabbed panel
I have an navigation-based app with three view controllers. The first has categories of
I have quite a large View Controller in my app and I want to
i have an app called blog and blog and Post and Categories model. url(r'^(?P<slug>[-\w]+)/$',
I have app in which i have recorded sound files i want that i
lets say i have app id, app secret id and user uid now i
new rails user here. I have a rails project that I want to accept
I have inherited a web app with the following tables: Categories, SubCategories and Pages.

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.