Forum: Ruby on Rails how to insert Current DateTime value into database?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Prashant T. (Guest)
on 2006-04-05 17:24
Hi,

I want to insert onto database the Current DateTime Value into database
field "Store_date" with datatype (DATETIME). How to do tihs?

I am usiing hidden variable into my form as follows:-
=======================
<%= hidden_field("store", "store_date", :value =>:datetime ) %>
=======================

But when I m submmittng form I couldn't find entry in store_date field.

How to do this using hidden variable?

Please help me.
Prashant
Alan F. (Guest)
on 2006-04-05 18:09
Prashant T. wrote:
> Hi,
>
> I want to insert onto database the Current DateTime Value into database
> field "Store_date" with datatype (DATETIME). How to do tihs?
>
> I am usiing hidden variable into my form as follows:-
> =======================
> <%= hidden_field("store", "store_date", :value =>:datetime ) %>
> =======================
>
> But when I m submmittng form I couldn't find entry in store_date field.
>
> How to do this using hidden variable?
>
> Please help me.
> Prashant

Prashant, please look at the documentation regarding created_on and
updated_on.  There' is no need to use a hidden field for thuis as rails
will automatically update certion fields for you.

See, for example,
http://wiki.rubyonrails.org/rails/pages/MagicFieldNames

As regards the hidden field, a quick google for "ruby on rails
hiden_field documentation" returned this:

http://railsmanual.org/module/ActionView%3A%3AHelp...

It looks like you're attempting to specify the data type (:datetime) in
the value field.  Is that correct ?

Alan
This topic is locked and can not be replied to.