Rails date_select fields hidden

Another 2 hours wasted. Today I was trying to use the date_select helper, but I could not figure out why the fields kept showing up as hidden inputs instead of select boxes.

Poked around for a long long long time, before catching this tidbit

: order – Set to an array containing :day, :month and :year do customize the order in which the select fields are shown. If you leave out any of the symbols, the respective select will not be shown (like when you set :discard_xxx => true. Defaults to the order defined in the respective locale (e.g. [:year, :month, :day] in the en locale that ships with Rails).

For some god forsaken reason, the “order” on the date_select field in my app was not set, or is defaulted to something else. I have no idea where this happens, or how it happens. But adding and order param fixed my problem

f.datetime_select :start_time, :order => [:year, :month, :day]
  • Lucca Mordente

    Thank you!

  • You are THE man! Thanks!

  • Pepan

    xx:
      date:
        order: 
          – :day
          – :month
          – :year

  • Gatis Tomsons

    thanks dude

  • Harold Daniel

    Thanks for this hint… would have taken me a while to figure this out. I tracked the source of the problem in my app to the config/locales/en.yml file, which had this line defined:

    order: [ year, month, day ]

    Removing the line fixed the issue. I’m not really using locale in my app, but these settings got copied in with an import of some code from someone else.