Skip to content

Instantly share code, notes, and snippets.

@rubiety
Created January 23, 2015 19:23
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 rubiety/7845d9d2467811d83415 to your computer and use it in GitHub Desktop.
Save rubiety/7845d9d2467811d83415 to your computer and use it in GitHub Desktop.
Dumping hidden fields from nested params hash
def hidden_fields_from_params(hash, prefix = "")
hash.map do |hash_key, hash_value|
if hash_value.is_a?(Hash)
hidden_fields_from_params(hash_value, "#{prefix}[#{hash_key}]")
else
hidden_field_tag("#{prefix}[#{hash_key}]", hash_value)
end
end.join("\n").html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment