When I add this to my model:

  def after_initialize
    :date = Date.today
  end

I get this error --  /home/xxdesmus/timetool/app/models/post.rb:38:
syntax error, unexpected '=', expecting kEND :date = Date.today ^

when I try it this way:

  def after_initialize
    date = Date.today
  end

It doesn't do anything ...probably because my field should have a
different name other than "date" huh?

On Mar 5, 11:43 am, Michael Pavling <[email protected]> wrote:
> On 5 March 2010 16:38, xxdesmus <[email protected]> wrote:
>
> > Hey, you don't happen to know of a simple way of implementing a date
> > picker for a field in a form do you? I was hoping to accomplish this
> > without needing to track down a plugin for the task.
>
> I've used the "calendar_date_select" plugin in the past - it is a
> plugin, but it's also very simple.
>
> > On a related note: how can I set the default value of a field to be
> > today's date (just the date, no time value)
>
> Again in the model (one of several ways to address the need) :
>
> def after_initialize
>   my_date_field = Date.today
> end

-- 
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