Skip to content

Instantly share code, notes, and snippets.

@jackdesert
Forked from hungpk/gist:5098340
Last active December 26, 2015 04:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jackdesert/7090731 to your computer and use it in GitHub Desktop.
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.
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