You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a small problem with version 1.0.0. I'm not sure whether it is a bug or me trying to do something I shouldn't. I came up with the following MWE:
As you can see, the name of the input type="hidden" is incomplete, and Rack raises an exception when the form is submitted. I thought that maybe using an Integer caused a problem somehow, so I replaced fields_for i do by fields_for i.to_s do but the result is the same. Only if I append or prepend a non-numeric character do I get to see the expected result.
The text was updated successfully, but these errors were encountered:
Because we're supporting fields_for_collection, we have a side effect that is that you can't have a subfield named by a numeric key (so user[1], user[1][foo] or just 1). Most of the time, if you think about doing something like that, you in fact want to have an array of items in the end
# so not this
{
users: {
"0": { user_id: "10", story: "..." },
"1": { user_id: "11", story: "..." }
}
}
# but this
{
users: [
{ user_id: "10", story: "..." },
{ user_id: "11", story: "..." }
]
}
In a nutshell: this is an unavoidable side effect (in the current architecture of the code) of the really cool feature fields_for_collection which you should definitively be using in your example and that would solve your problem :)
If you want to avoid it, you just need to use an alphanumeric key (ie: n0 instead of 0)
Hi,
I ran into a small problem with version
1.0.0
. I'm not sure whether it is a bug or me trying to do something I shouldn't. I came up with the following MWE:It produces the following HTML code:
As you can see, the
name
of theinput type="hidden"
is incomplete, and Rack raises an exception when the form is submitted. I thought that maybe using an Integer caused a problem somehow, so I replacedfields_for i do
byfields_for i.to_s do
but the result is the same. Only if I append or prepend a non-numeric character do I get to see the expected result.The text was updated successfully, but these errors were encountered: