Created
September 21, 2011 07:26
-
-
Save nashby/1231462 to your computer and use it in GitHub Desktop.
fix for broken :all_blank in rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nested_all_blank(attributes) | |
attributes.reject { |key, value| ['_destroy', :_destroy].include?(key) && [false, 0, 'f', 'false'].include?(value) }.all? do |_, value| | |
if value.is_a?(Hash) | |
nested_all_blank(value) | |
else | |
value.blank? | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment