in my def create controller I'd 开发者_JS百科like to include something along the lines of:
:description = > 'Uploaded on May 27, 2010"
How can I make the May 27, 2010 dynamic in the controller?
Thanks!
Try this!
:description => "Uploaded on #{Date.today.strftime("%b %d,%Y")}"
I assume when you say you want to make May 27, 2010
then you mean you want to set the current date. For that you need to use:
:description = > "Uploaded on " + Time.now.to_s
Output will be:
"Uploaded on Fri Oct 22 21:48:49 -0700 2010"
There are many options in the Time class which you can use. This is an interesting read for timezone consideration for Rails.
精彩评论