Skip to content

Instantly share code, notes, and snippets.

@signaes
Created February 18, 2020 22:29
Show Gist options
  • Save signaes/f2f6a9c8dc766e0bfddcffd4f62d39c0 to your computer and use it in GitHub Desktop.
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
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
@pichotweb
Copy link

Tricky! helped me 3 years later! ;) Thanks!

@signaes
Copy link
Author

signaes commented May 12, 2023

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!

@jan-kozinski
Copy link

just what I needed. Thanks man!

@signaes
Copy link
Author

signaes commented Mar 13, 2024

just what I needed. Thanks man!

Glad it helped!

@amila03ac
Copy link

Helped me today! Neat!

@signaes
Copy link
Author

signaes commented Apr 5, 2024

Helped me today! Neat!

🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment