How to insert Current DateTime value into database?


#1

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


#2

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%3AHelpers%3A%3AFormHelper#hidden_field

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

Alan