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 |
Tricky! helped me 3 years later! ;) Thanks!
I didn’t even remember it :), I probably got this from somewhere else, but I am glad it helped!
just what I needed. Thanks man!
just what I needed. Thanks man!
Glad it helped!
Helped me today! Neat!
Helped me today! Neat!
🙌
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tricky! helped me 3 years later! ;) Thanks!