I have a form which i'd like to simplify. I'm recording a startdate and an enddate, but would like to show the user only a startdate and then a drop down with number of days.
But I'm having problems with my model and storing it correctly.
The first part works.
def date=(thedate)
#puts the startdate in the correct format...
self.startdate = Date.strptime(thedate, '%m/%d/%Y')
end
The problem I have has to do with the fact that the end date is based on the startdate + the no_days which is itself a virtual attribute. I tried doing the second part as a after_validation callback but it doesn't seem to work.
def set_dates
if self.startdate
self.enddate = self.startdate + days
end
end