Turn off RoRs automatic timezone conversion for columns
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!
Share This
— Trackback URI
This entry (permalink) was posted on Saturday, November 1, 2008, at 10:15 am by Michael, tagged with Code Snippets, Tipps and categorized in English posts, Rails.
The following post could be of some interest: Ruby On Rails the Java Way: Grails, Absurdistan (1), A little vpn zoo, Turn ruby heredocs from double-quoted into sinqle-quoted strings, Using Hibernate with Oracle Spatial, JDBC: Get autogenerated keys on a Oracle DB, Disable Ruby On Rails Sessions, WordPress 2.5 and http error codes, Optimizing the Oracle Query Optimizer, Mac OS X Lion loses network connection after sleep
2 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 !
Post a Comment