djlsdq
Last Updated: February 25, 2016
·
533
· joshuap
B7632770a85e03b597b031477c8c24bc

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

Say Thanks
Respond