Fixes issue with "null" being displayed in drop down#70
Fixes issue with "null" being displayed in drop down#70macfanatic wants to merge 1 commit intogregschmit:masterfrom
Conversation
|
Nice, I was noticing this was an issue for me as well. Maybe you can update the tests to match this change here to get it merged. |
All the code checks for presence, but the db stores the string “null”. For backwards compatibility, the fix could be to update all the checks to ensure that “null” is considered a blank string essentially, but for our project adding this for the first time we decided to just store nil in the database as the proper solution.
2770b74 to
1c1c69d
Compare
|
@macfanatic First of all, thanks for the contribution and sorry for the slow response. Looking at this, I believe the reason this was done using the "null" string is that in Rails if you pass nil as the selected option to options_for_select it doesn't look for an option with a blank value to mark as selected, but instead ignores it like there wasn't a selected option. This means that if you have a blank value anywhere in the options that isn't the first option, then the select element won't reflect the selected option. I think the better way to address this would be to find any places that aren't correctly identifying "null" and fix those. I wasn't able to find any with a quick survey, but if you could make a PR fixing this from that angle I'd be happy to merge that in. |
|
@benzittlau Thanks for this. What is the recommended way to handle the null being displayed in the select? |
|
@benzittlau Thanks How to render a exist model with |
All the code checks for presence, but the db stores the string “null”.
For backwards compatibility, the fix could be to update all the checks
to ensure that “null” is considered a blank string essentially, but for
our project adding this for the first time we decided to just store nil
in the database as the proper solution.