On 5 March 2010 16:43, Michael Pavling <[email protected]> wrote:
> Again in the model (one of several ways to address the need) :
>
> def after_initialize
>  my_date_field = Date.today
> end
>

Sorry - that's bad - it will always reset the value to today even if
there is an existing value...

This will just set it if the "my_date_field" value is nil:

 my_date_field ||= Date.today

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to