Forum: Ruby on Rails type cast after attributes=

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B5feafb2c66fdff60029deda63f99f93?d=identicon&s=25 dweinand (Guest)
on 2007-04-13 08:41
(Received via mailing list)
i have a problem with setting attributes.

Read from the DB. This attribut exists, fieldtype in DB is timestamp
"uebergabe_datum"=>"2007-04-03 10:32:00"

setting the attributes in controller with params=
objekt.attributes = params[:my_params]

results in this:
"uebergabe_datum"=>#<DateTime: 441754909/180,0,2299161>

Everything like expected.

But there's a case where the field "uebergabe_datum" isn't in the
params hash.
objekt.attributes isnt't casting the attribut, cause it isn't

"uebergabe_datum"=>"2007-04-03 10:32:00"

after attributes=:
"uebergabe_datum"=>"2007-04-03 10:32:00"

with this value i'm not able to save the record.

how to get this: "uebergabe_datum"=>#<DateTime:
without the attribut in the params? i'm looking for something like

This topic is locked and can not be replied to.