@@ -403,6 +403,46 @@ There are also rake tasks available, for convenience:
403
403
$ rake mongoid:db:remove_search_indexes
404
404
405
405
406
+ ``Time.configured`` has been removed
407
+ ------------------------------------
408
+
409
+ ``Time.configured`` returned either the time object wrapping the configured
410
+ time zone, or the standard Ruby ``Time`` class. This allowed you to query
411
+ a time value even if no time zone had been configured.
412
+
413
+ Mongoid now requires that you set a time zone if you intend to do
414
+ anything with time values (including using timestamps in your documents).
415
+ Any uses of ``Time.configured`` must be replaced with ``Time.zone``.
416
+
417
+ ... code-block:: ruby
418
+
419
+ # before:
420
+ puts Time.configured.now
421
+
422
+ # after:
423
+ puts Time.zone.now
424
+
425
+ # or, better for finding the current Time specifically:
426
+ puts Time.current
427
+
428
+ If you do not set a time zone, you will see errors in your code related
429
+ to ``nil`` values. If you are using Rails, the default time zone is already
430
+ set to UTC. If you are not using Rails, you may set a time zone at the start
431
+ of your program like this:
432
+
433
+ ... code-block:: ruby
434
+
435
+ Time.zone = 'UTC'
436
+
437
+ This will set the time zone to UTC. You can see all available time zone names
438
+ by running the following command:
439
+
440
+ ... code-block:: bash
441
+
442
+ $ ruby -ractive_support/values/time_zone \
443
+ -e 'puts ActiveSupport::TimeZone::MAPPING.keys'
444
+
445
+
406
446
Bug Fixes and Improvements
407
447
--------------------------
408
448
0 commit comments