Forum: Ruby on Rails RoR date_select() default date

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
13d97799b5e78838c4c9d8d1fc67109e?d=identicon&s=25 mehdi (Guest)
on 2006-02-28 23:20
Hi,
I'm trying to use the date_select() function of ruby on rails, but I
want my form  easier to use and I want to put an explicit default date.
I don't kow how to do that. I can't find any information about default
on the web, and no example either.

Let me know if there is a tips that I don't know...
Bf66e10c8fc4abefebde0425e7f6f15a?d=identicon&s=25 Norman Timmler (Guest)
on 2006-03-01 10:09
(Received via mailing list)
Am Dienstag, den 28.02.2006, 23:20 +0100 schrieb mehdi:
> Hi,
> I'm trying to use the date_select() function of ruby on rails, but I
> want my form  easier to use and I want to put an explicit default date.
> I don't kow how to do that. I can't find any information about default
> on the web, and no example either.
>
> Let me know if there is a tips that I don't know...

>From the Rails API Documentation:

"date_select(object, method, options = {})

Returns a set of select tags (one for year, month, and day) pre-selected
for accessing a specified date-based attribute (identified by method) on
an object assigned to the template (identified by object)."

I give you an example:

# Controller:
def new
  @invoice = Invoice.new(:date_of_issue => Date.today)
end

# View:
<%= date_select 'invoice', 'date_of_issue' %>

The date_select helper will display the date of today as default. Change
the date in the controller, and the default date in the view will
likewise.

--
Norman Timmler

http://blog.inlet-media.de
This topic is locked and can not be replied to.