Problem setting date of album release
Closed this issue · 2 comments
chrislo commented
chrislo commented
- I notice I am able to set a later
released_on
date through the rails console and the model successfully saves with no validation errors - I can't seem to reproduce this bug locally
- The date in the error message
2024-01-21
matches the last deployment date of the web server in render:
![Screenshot 2024-02-13 at 20 59 11](https://private-user-images.githubusercontent.com/16707/304546974-5dd0c517-684f-465c-8d09-88a15a1483eb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxMTE3NDQsIm5iZiI6MTcyMDExMTQ0NCwicGF0aCI6Ii8xNjcwNy8zMDQ1NDY5NzQtNWRkMGM1MTctNjg0Zi00NjVjLThkMDktODhhMTVhMTQ4M2ViLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA0VDE2NDQwNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUzNmQwMjcyODdiOWRjNjc2N2Q1NzE1Njg0ZmY4NjY5MjJhM2Y3MTdjMWNiODYwMzBkMDY3NDRmNTI2N2RlYWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.GmNEUoMmouk8hLTIeOQARuaCJhtW8MDIwsaM8FSzJFE)
This makes me wonder whether the validation line in app/models/album.rb
is somehow caching or closing over the value of Time.zone.today
the first time it is called or the server is booted.
Does that sound remotely plausible @floehopper?
chrislo commented
I restarted the server and was able to set the released_on date to today (and other dates later than 2024-01-21
). So I think it's plausible that the released_on
validation code in album.rb is executed when the application starts and evaluates Time.zone.today
at that time. I'll see if there's a way to make it dynamically evaluate the validation code each time it is used.