Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change recorded variables created_at property

Is there a way to change a database records "created_at" variable after it created?

like image 868
gkaykck Avatar asked Feb 25 '11 17:02

gkaykck


1 Answers

Sure, since rails 2.3 you can change it like any other column: get the object from the database, set the value for the column, save it.

my_model = MyModel.find(42)
my_model.created_at = Date.today
my_model.save
like image 190
sepp2k Avatar answered Nov 16 '22 17:11

sepp2k