I am trying to prevent changes to time entries, if the spent_on time is from previous months:
spent_on = read_attribute(:spent_on)
today = Date.today
if (spent_on.year <= today.year) && (spent_on.month < today.month) && (today.day > 5)
errors.add '', 'You are not allowed to change time entries from the previous month.'
end
which always results in the error
undefined method 'year' for nil:NilClass
I am trying to prevent changes to time entries, if the spent_on time is from previous months:
which always results in the error
undefined method 'year' for nil:NilClass