Imagine I have a Post Model.
and one record in the database will be:
23|title_here|content_here|2011-02-20 08:01:55.583222|2011-02-20 08:01:55.583222
and the last two field (2011-02-20 08:01:55.583222|2011-02-20 08:01:55.583222
) are the created_at and updated_at field.
Then,
post = Post.find_by_id(23)
Question: How can I get the created_at string: "2011-02-20 08:01:55.583222
" in the data base?
As we know, the post.created_at will return a ActiveSupport::TimeWithZone
object, not the raw string.
Please help :)
Try
use attributes_before_type_cast
or
Edit
You can call like this also:
according to Accessing attributes before they have been typecasted link.