ActiveRecord model doesn't show timestamps

All ActiveRecord models in my Rails app recently showed a strange behavior relating to timestamps: The can be saved in the database (sqlite3 for development), but a loaded model only has 'nil' fields.

Saving:

SQL (0.5ms)  UPDATE "users" SET "confirmed_at" = ?, "updated_at" = ?, "user_type_id" = ?     
WHERE "users"."id" = 1  [["confirmed_at", "2014-06-07 13:50:27.437678"], ["updated_at", 
"2014-06-07 13:50:35.680003"], ["user_type_id", 1]] 

Loading:

=> #<User id: 1 ... created_at: nil, updated_at: nil ... confirmed_at: nil, ...> 

When directly accessing the database, I can see all timestamps in the 'saving'-format. Any suggestions?

Answers


This behavior appears because of some settings I made at the very beginning. In application.rb I set the following:

config.time_zone = 'Berlin'
config.active_record.default_timezone = 'Berlin'

This causes a loading error as active_record.default_timezone can't be set like the application's time_zone. To prevent this, I updated my code:

config.time_zone = 'Berlin'
config.active_record.default_timezone = :local
config.active_record.time_zone_aware_attributes = false

Need Your Help

How to pass Hidden field Value from html page to GWT page ? both page in different application

java javascript html gwt servlets

How do I pass a hidden field value from one application(html) page to GWT page? Access them in destination i.e. GWT PAGE , both pages in different application

Looking for help in building a youtube video slider in asp.net

javascript jquery asp.net ajax youtube

I'm currently learning asp.net to learn how to make web applications. I have a goal of creating a youtube type video slider for my website, so I can display videos. I was wondering if anyone can po...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.