Created
February 18, 2020 22:29
-
-
Save signaes/f2f6a9c8dc766e0bfddcffd4f62d39c0 to your computer and use it in GitHub Desktop.
Using active support time helpers to change the current date in the rails console
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 'active_support/testing/time_helpers' | |
# the class below could have any name | |
class Tempo | |
include ActiveSupport::Testing::TimeHelpers | |
end | |
# any desidered date | |
desired_date = Date.today - 2.days | |
Tempo.new.travel_to desired_date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Helped me today! Neat!