Skip to content

Instantly share code, notes, and snippets.

@danbt79
Created April 7, 2012 15:59
Show Gist options
  • Save danbt79/2329943 to your computer and use it in GitHub Desktop.
Save danbt79/2329943 to your computer and use it in GitHub Desktop.
# Musings on <select> inputs:
# (aka: how Rails is doing it right.)
# This is what Rails looks like in the books:
f.date_select :end_date
# This is what Rails looks like in production:
f.date_select :end_date, {:include_blank => false, :start_year => Time.zone.now.year, :end_year => (Time.zone.now + 2.years).year, :order => [:month, :day, :year], :prompt => {:month => t(:select_month), :day => t(:select_day), :year => t(:select_year)} }, {:class => 'datetime_picker'}
# The second may be long, but it's still just a single line.
# It is also:
# * pre-populated with our objects values
# * ordered as the client requested.
# * styled with a beautiful jQuery date picker.
# * sensitive to the User's timezone.
# * translated into 8 different languages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment