I’m creating a timesheet application where a “Timesheet” object has 7
“TimesheetDays” objects. Everything works fine until error validation
or a ‘preview’ (after calculations) when the form is re-rendered. The
data in the fields for the Timesheet object persist after render, but
all my text input fields for each of the TimesheetDay objects reset. I
know I’m doing something wrong here, but I need the data the use
entered into the TimsheetDay fields to remain. Please help!!
Yes, Ruby F., the data isn’t saved, but in “Preview Mode” for
calculating totals before confirming. I don’t think that’s the problem
because the Timesheet attributes persist, only the TimesheetDay object
attributes are cleared. Maybe I need to add the user-entered data to a
cookie or the session?
I’m tempted to just hard-wire the entire timesheet into a 1 week deal,
but it seems hackish to me. I’m going to the Pragmatic Programmers
Advanced Rails workshop next week. I’ll ask them and update my post.
This might be a stupid observation, but isn’t your code falling out to
render :action => ‘new’ before save ever gets called?
week_select @timesheet = Timesheet.new(params[:timesheet])
render :action => ‘new’ #code is falling out here and never
elsif [email protected]
render :action => ‘new’
# some stuff…