Results 1 to 7 of 7
Thread: Rails: Set default model values
Nov 6, 2005, 16:44 #1
- Join Date
- May 2003
- 0 Post(s)
- 0 Thread(s)
Rails: Set default model values
I have a model called Product. The Product has date_modified and date_created fields. I'd like to set the value to now() (mysql). I thought it'd be as simple as setting the value in the controller.create method:
@product = Product.new(params[roduct])
@product.date_created = 'now()'
The 'now()' value needs to be un-escaped: values(now(), 'string', etc..)
But that doesn't do it. What gives? Also, is there a way to do this in the model?