I couldn’t find this in the documents, but Geoff Buesing showed me the hooks to turn off Ruby On Rails’ automatic timezone conversions for some columns of a model or a complete model:
# Turn it off for just some columns class Picture < ActiveRecord::Base def self.skip_time_zone_conversion_for_attributes [:created_at, :published_at] end end # Turin it off for the whole model class Picture < ActiveRecord::Base def self.time_zone_aware_attributes false end end |
Thanks a lot!
6 comments
Hi ,
Actually I am developing rails front end application to integrate back end application via database . Not standalone Rails applications development.
Highly appreciation for the rails developer to get the timezone as default also very easy to configure timezone .
But when we talk about integrated application as like me that is java and rails both application access the same database where the situation
I don’t like time conversion according to different timezones .
So really it is very useful for me to integrate rails with java..etc without timezone conflict .
I was looking for the answer to that question all day. It works great. Thanks a lot !
Thank you. For a schedule of events for a physical business, time zone is not important. This helped us greatly. Much appreciated.
Thank you for this. Been trying to figure out this issue all day and finally stumbled on this post.
You’re welcome Josh! Does this still work in newer Rails versions? Nice!
Thanks! Saved my life. Well, not literally, but definitely helped 😉
Post a Comment