ruby - Setting up Time.zone in Padrino -
i having problem setting default activesupport::timezone in padrino project.
in boot.rb have
padrino.after_load time.zone = 'utc' activerecord::base.default_timezone = :utc end
my controller file has:
myapp::app.controllers :post :index puts time.zone # returns nil render 'index' end end
when nail index action nil time.zone. seems though might overwriting time.zone or isn't loaded properly.
i able print out timezone after setting in boot.rb. know set.
in boot.rb
i've got:
padrino.before_load time.zone = 'utc' end
and in database.rb
:
activerecord::base.default_timezone = :utc
which having tested in console seems work:
ruby-2.1.4$ padrino c => loading development console (padrino v.0.12.4) 2.1.4 :001 > time.zone => #<activesupport::timezone:0x007fbff62ed5c0 @name="utc", @utc_offset=nil, @tzinfo=#<tzinfo::timezoneproxy: etc/utc>, @current_period=#<tzinfo::timezoneperiod: nil,nil,#<tzinfo::timezoneoffset: 0,0,utc>>>> 2.1.4 :002 > time.zone.now => tue, 30 dec 2014 13:14:57 utc +00:00 2.1.4 :003 > time.current => tue, 30 dec 2014 13:15:01 utc +00:00 2.1.4 :004 > activerecord::base.default_timezone => :utc
n.b. tested ruby v2.1.4, padrino v0.12.4, activesupport/activerecord v4.2.0.
ruby timezone padrino
No comments:
Post a Comment