Skip to content

Loading…

date_select with both discard_day and include_blank may be broken in 3.2 #4633

Closed
hab opened this Issue · 3 comments

3 participants

@hab

I have a regression between Rails 3.1 and 3.2 that appears to be introduced by pull request #2086.

I have a form with a date_select like this:

   date_select 'bill', 'payment_month', discard_day: true, include_blank: true

In Rails 3.1 that worked fine as the multi-parameter conversion in ActiveRecord automatically added a 1 (one) for each missing parameter. However, Rails 3.2 (with pull request #2086) changed this behaviour to return nil if any of the multi-parameters were missing. That effectively means that it is no longer possible to use the above combination.

The date_select will provide a default day-value in a hidden field only if include_blank is false. A possible solution may be to change this behaviour to always add hidden fields with default values regardless of the include_blank parameter as it would simply be discarded now.

@rafaelfranca
Ruby on Rails member

Could you try to add a falling test or open a pull request?

@hab

I am not entirely sure where I should add a failing unit test. It is the combination of date_select and the multi-parameter conversion that fails for me.

The easy fix for my case would be to change date_select to add a value to the hidden day parameter but that would change a behavior that has not changed in years.

Can you give me a hint on what you would like to see?

@rafaelfranca
Ruby on Rails member

This issue is related with #4553. I'm taking a look in this

@rafaelfranca rafaelfranca added a commit to rafaelfranca/omg-rails that referenced this issue
@rafaelfranca rafaelfranca Fix date_select with discard_month and discard_year options
Closes #4553 and #4633
c4b7ca0
@josevalim josevalim closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.