In this commit the params
option was added to the button_to
helper. However, the patch doesn’t support nested hashes so {a: {b: 'c'}}
for example gets turned into a hidden form input with the name ‘a’ and the value being the string representation of the {b: 'c'}
nested hash.
Since Rails supports nested hashes everywhere else (and even in the URL params of link_to and button_to), I believe this to be a bug/unfinished feature. Unless the other disagree with that assessment, I’m planning to submit a patch to add the missing functionality.
I had question though on implementation: I can’t find any support in Rails for turning a nested hash into a list of name/value pairs for form inputs. to_query
exists on Hash, of course, but it specifically escapes the keys and joins the keys and values as fits a URI. In my patch I can either write one-off code within the button_to helper to accomplish what I need, or I can add a new Hash extension to ActiveSupport. What’s the best/expected way to go about tackling this issue?
Thanks,
James