Skip to content

Instantly share code, notes, and snippets.

@nashby
Created September 21, 2011 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nashby/1231462 to your computer and use it in GitHub Desktop.
Save nashby/1231462 to your computer and use it in GitHub Desktop.
fix for broken :all_blank in rails
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