How to get the raw ‘created_at’ value in the database (not an object cast to an ActiveSupport::TimeWithZone)

use attributes_before_type_cast

Post.find(23).attributes_before_type_cast["created_at"]

or

Post.find(23).read_attribute_before_type_cast("created_at")

Edit

You can call like this also:

Post.find(23).created_at_before_type_cast

according to Accessing attributes before they have been typecasted.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)