Append a timestamp to file

im doing following code but it gives error
temp=Time.now.to_s
file_name = “#{temp}_”+
params[:group_member_information].original_filename

so please reply how to append a timestamp to file name

you could do something like that:

file_name =
“#{Time.now.to_s}_#{params[:group_member_information].original_filename}”

but this would give you a time looking like
Wed May 07 11:26:57 +0200 2008

so using
Time.now.to_s(:db)
would look better

but it gives error

what error?
the code would be ok, if the params[:group_member_information] would be
an uploaded file, what it most likely is not. so the error has most
likely nothing to do with the Time or the filename you generate but with
that param.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs