datetime_select(object_name, method, options = {}) public

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

Examples

  # Generates a datetime select that, when POSTed, will be stored in the post variable in the written_on attribute
  datetime_select("post", "written_on")

  # Generates a datetime select with a year select that starts at 1995 that, when POSTed, will be stored in the
  # post variable in the written_on attribute.
  datetime_select("post", "written_on", :start_year => 1995)

  # Generates a datetime select with a default value of 3 days from the current time that, when POSTed, will be stored in the
  # trip variable in the departing attribute.
  datetime_select("trip", "departing", :default => 3.days.from_now)

  # Generates a datetime select that discards the type that, when POSTed, will be stored in the post variable as the written_on
  # attribute.
  datetime_select("post", "written_on", :discard_type => true)

The selects are prepared for multi-parameter assignment to an Active Record object.

Show source
Register or log in to add new notes.