Flowdock
select_date(date = Date.today, options = {}) public

Returns a set of html select-tags (one for year, month, and day) pre-selected with the date. It’s possible to explicitly set the order of the tags using the :order option with an array of symbols :year, :month and :day in the desired order. If you do not supply a Symbol, it will be appended onto the :order passed in.

Examples

  my_date = Time.today + 6.days

  # Generates a date select that defaults to the date in my_date (six days after today)
  select_date(my_date)

  # Generates a date select that defaults to today (no specified date)
  select_date()

  # Generates a date select that defaults to the date in my_date (six days after today)
  # with the fields ordered year, month, day rather than month, day, year.
  select_date(my_date, :order => [:year, :month, :day])

  # Generates a date select that discards the type of the field and defaults to the date in
  # my_date (six days after today)
  select_datetime(my_date_time, :discard_type => true)

  # Generates a date select that defaults to the datetime in my_date (six days after today)
  # prefixed with 'payday' rather than 'date'
  select_datetime(my_date_time, :prefix => 'payday')
Show source
Register or log in to add new notes.
January 28, 2016
0 thanks

the method to make 'day' disappear.

If you wanna show “year” and “month” only, you can use “order” to do it:

select_date(Date.current, order: [:year, :month])

That’s it.