Multiple Dates in a table - ugh!

Hi:

I have a table that has 3 datetime fields.

The first functions like a normal timestamp; I don’t handle it specially
in my create

method, and it’s updated just fine. It’s called “created_on”

The second is supposed to be a “last_updated” field, as it’s important
to know when

something was created and when it was last updated.

The third datetime field is meant to attach a user-defined date to the
record in the table.

I’m trying to set the second two manually, with certain input. I can’t
get either of them to

update. On the second, in my controller I’m trying:

@goal.last_updated = Time.now

On the third, I’m trying to capture user input with (inside a form
already):

<%= f.date_select :duedate %>

Neither the second or the third are being updated in the table. What am
i doing wrong?

Thanks so much in advance!

Mike

Keynan P. wrote:

the last_updated field will be handled by rails automatically if you use
updated_at/on however to solve the other problem more info would be a
help.

specifically
the controller/model/view that your working with

Keynan:

Thanks very much for your help. I’ve been able to get the “created_on”
and “last-updated” working now, but I still can’t get the “duedate”
working. I wonder if it’s becuase the input that I’m feeding it is not
a full timestamp, but only the date in various formats (even text input
02/09/2007, e.g.)

That being said, here’s the relevant controller code:

@goal = Goal.new(params[:goal])

#store the userid for this goal
@goal.entity_id = session[:user].id
@goal.last_updated = Time.now

  if @goal.save
tags.each {|tag| @goal.tags << Tag.find_or_create_by_name(tag)}
@goalhist.goal_id = @goal.id
#big if for creating the actual measurements
@goalhist.save!
    flash[:notice] = 'Goal was successfully created.'
    #format.html { redirect_to goal_url(@goal) }
    format.html { redirect_to goals_path }
    format.xml  { head :created, :location => goal_url(@goal) }
  else
    format.html { render :action => "new" }
    format.xml  { render :xml => @goal.errors.to_xml }
  end
end

View:

<%= f.date_select :duedate %>

No code in the model:

Again, any help you could provide would be great!

Mike

the last_updated field will be handled by rails automatically if you use
updated_at/on however to solve the other problem more info would be a
help.

specifically
the controller/model/view that your working with