Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11119 (closed defect: invalid)

Opened 7 months ago

Last modified 7 months ago

datetime_select does not work with :default

Reported by: bluestar Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords:
Cc:

Description

According to this http://dev.rubyonrails.org/ticket/7052

datetime_select should now accept a default value.

However, this does not work when the model does not have a field for the given datetime. This problem has been encountered by other users on ruby-forum.com

In the following, "trade" is not a model, but simply a field:

This gets the current date time instead of a date with year 1995: <%= datetime_select :trade, :opened_at, :default => 1995%>

Similarly, this doesn't work: <%= datetime_select :trade, :opened_at, :start_year => 1995%>

In all cases, the default value displayed by the view is the current time and date.

Change History

02/15/08 06:53:07 changed by blj

  • status changed from new to closed.
  • resolution set to invalid.

I am afraid you have to set the default value for your model object instead. This is not a defect.

try in your new action or whatever,

 @trade.opened_at = Date.today