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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:26:46+00:00 2026-05-16T03:26:46+00:00

When I save an apartment record in rails, for some reason it is updating

  • 0

When I save an apartment record in rails, for some reason it is updating the updated_on field and the created_on field. I can’t figure out how/why the created_on field is being updated.

To try and debug the situation, I opened up a console window and did the following

t = Apartment.find(11619)
t.beds = 4
t.save

When I check my log file, I see the following

   SQL (0.0ms)   BEGIN
   Apartment Load (0.0ms)   SELECT `apartments`.id FROM `apartments` WHERE (`apartments`.`unit_num` = BINARY '2005' AND `apartments`.building_id = 17755 AND `apartments`.id <> 11619) LIMIT 1
   Apartment Load (0.0ms)   SELECT * FROM `apartments` WHERE (`apartments`.`id` = 11619) 
   Apartment Update (0.0ms)   UPDATE `apartments` SET `beds` = 4.0, `updated_on` = '2010-07-31 19:54:10' WHERE `id` = 11619
   SQL (0.0ms)   COMMIT

This shows only the updated_on field being changed!

So I guess the question is, what could change my created_on value and yet not show up in the rails log file?

EDIT: I know the created_on field is changing because when I do a sql query to check, the value has been updated to be the same as the updated_on field. Also, I display the created_on value to my users, which is what brought this bug to my attention.

EDIT2: The table definition is as follows. I seemed to have solved my problem by changing the default value from “CURRENT_TIMESTAMP” to “0000-00-00 00:00:00”, though I don’t understand why this would make a difference?

Field   Type    Null    Key Default Extra
id  int(10) unsigned    NO  PRI \N  auto_increment
building_id int(10) unsigned    YES MUL 0   
unit_num    varchar(45) YES         
beds    float   YES MUL \N  
rent    int(10) unsigned    YES MUL 0   
date_available  date    YES     \N  
on_market   tinyint(1)  YES     0   
floor   varchar(10) YES     \N  
fee_paid    int(10) YES     0   
note    blob    YES     \N  
created_by  int(10) unsigned    YES     1   
updated_by  int(10) unsigned    YES     1   
created_on  timestamp   NO      CURRENT_TIMESTAMP   
updated_on  timestamp   NO      0000-00-00 00:00:00 
lease_expiration_date   date    YES     \N  
on_market_date  date    YES     \N  
off_market_date date    YES     \N  
tenant_name varchar(40) YES     \N  
tenant_number   varchar(40) YES     \N  
baths   float   YES     1   
public_note blob    YES     \N  
public_title    text    YES     \N  
key_note    blob    YES     \N  
status  varchar(40) YES     Off Market  
app_pending tinyint(1)  YES     0   
app_pending_date    date    YES     \N  
  • 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-16T03:26:47+00:00Added an answer on May 16, 2026 at 3:26 am

    Based on the suggestion by Chris Henry, I took a look at my table definition and changed the default value from “CURRENT_TIMESTAMP” to “0000-00-00 00:00:00”. This fixed the issue, though I don’t understand why this would make a difference in my case

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

Sidebar

Related Questions

i save in mysql database the time using NOW() function. how can i change
How save insert sctipts in separate sql files in MySqlWorkbent? I can create database
I am trying to save a record which has a many-to-one property mapping. I
I save in a file some info about users (like number of times user
To save some space in my code, I made this typedef: typedef clients.members.at(selectedTab) currentMember;
when save() executes this.reset() or that.reset() it can't find the reset() method and says
I save some important info in $_SESSION , not in $_COOKIE . So, my
Some Save as dialogs provide a default file name - how is it done?
Please save me from myself (or reassure me that I'm not being completely misguided)
I save some values from database using this function (i've been replaced Vector, because

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.