Last Updated: February 25, 2016
·
711
· joshuap

Hack ActionView's date_select helper to apply individual class names to select tags.

For better or worse, in all its glory:

<%=
  date_order = [:month, :day, :year]
  date_class = lambda { date_order.pop.to_s }
  def date_class.to_s ; self.call ; end
  form.date_select(:date, { order: date_order.dup }, { class: date_class })
%>

Disclaimer: This is either a protip, or reason to hide in shame :).

"Sometimes it's both" - @StarrHorne