I just can’t seem to figure this out. I think I’m just looking in the
On an “edit post” page, I want users to be able to either specify their
own “created_at” date/time or let it default to “now”. The way I have
it set up right now is I have two radio buttons, one with a label of
“Now” and the other with a label of “Custom”, with a datetime_select
set to the post’s created_at attribute next to the Custom choice.
When they save their changes, it updates the post object with the
.update_attributes method. This automatically aggregates the
datetime_select’s values and inserts that value in the created_at
However, I want to intercept that and have it inject Time.now if the
user has selected the Now radio button.
I have tried doing a params[:post][:created_at] = Time.now; before I do
a @post.update_attributes(params[:post]); but it doesn’t seem to change
the created_at value. It still uses whatever was in the
Any ideas what I’m doing wrong here?