Skip to content

Commit

Permalink
accoutn for nils
Browse files Browse the repository at this point in the history
  • Loading branch information
johrstrom committed Oct 15, 2024
1 parent 6dcfb55 commit 0ef0ef6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/dashboard/app/lib/smart_attributes/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ def select_choices(hide_excludable: true)
end
end.map do |entry|
# always cast to array so other layers can try .first & .second for labels and values.
entry.is_a?(Array) ? entry : [entry, entry]
# and let nils fall through and get caught in validate!
if entry.is_a?(Array)
entry
elsif entry.is_a?(String)
[entry, entry]
end
end
end

Expand Down

0 comments on commit 0ef0ef6

Please sign in to comment.