Rails doesn't recognize a request as PATCH

While digging around a larger app I came across a problem with form for updating records. It turns out the problem is caused by a combination of hidden/select tag. When both fields are present it sends a POST request and fails with an error (route not found). With a single field the request is correctly recognized as PATCH.

Part of the code is used for dynamically adding languages to a model and storing it into hstore column. When there are no languages I’d like to send an empty value to reset the field.

I’ve created a sample app which reproduces this error. It’s nothing more than a blank rails app with hstore field on AR model. Can anyone help me explain what’s going wrong here?

Hi, this is probably not at all related to h-store. If you have a form using the form_for helper and all the fields you include are not using the yielded form builder object, none of them will be signed with the authenticity token and the request will fail. This, to the best of my knowledge is one of the security features in rails.

If you want to use hidden fields with the form_for, I’d recommend using the ones provided with that API: `form.hidden_field ‘key’, value: ‘the_value_you_want_to_pass’

Hope this helps!