-
-
Save catogonzalez/8e9221ef302ebef84710ea4412f3ecde 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 hidden or 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