-
-
Save jackdesert/7090731 to your computer and use it in GitHub Desktop.
This monkey patch of rails_admin allows me to set the timezone for rails_admin models explicitly, while the rest of the app runs on utc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_admin/config/fields/base' | |
module RailsAdmin | |
module Config | |
module Fields | |
module Types | |
class Datetime < RailsAdmin::Config::Fields::Base | |
def value | |
value_in_default_time_zone = bindings[:object].send(name) | |
return nil if value_in_default_time_zone.nil? | |
pacific_time_zone = ActiveSupport::TimeZone.new('Pacific Time (US & Canada)') | |
value_in_default_time_zone.in_time_zone(pacific_time_zone) | |
end | |
end | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment