Closed lucasfais closed 2 years ago
Hi,
Thanks for this report, I can confirm.
I've identified the issue and I do not recommend to use CSV with Rails 7.
There is something wrong and I do not have a clear clue on both how to fix this behavior and why the tests didn't find the bug.
The problem is here:
On localhost, I cannot even add validate: true
to a basic form_with
and I get
undefined method `content_tag' for ActionView::Base:Class
without a backtrace
As a workaround, if CSV works for your use case, ~please manually add the hidden field with the method to the form element~ pass the method in html
options:
= simple_form_for @model, url: my_action_path, remote: true, validate: true, html: { method: :patch } do |f|
PR (and a failing spec) are very welcomed
20.0.1 released, thanks
Awesome. I'm actually using rails 6.1.4.4. I'll test with the new gem version. Thanks!
I can confirm 20.0.1 fixes the issue with rails 6.1.4.4. Thank you!
I've splitted the other issue I've found while investigating this into #869
I've also understood why the tests pass. The other issue is related to Rails 7, so it should not be a problem on 6.1
Steps to reproduce
We have a rails app using
client_side_validations
and we had problems updating it from to19.1.1
to20.0.0
.A few forms using
client_side_validations
are issuing the request with the wrong HTTP method, resulting in a 404.For example, action defined as
PATCH
, butPOST
is used.Our forms are defined with
simple_form_for
and we are specifying the correct http method viamethod:
argument.I noticed that, on 20.0.0,
<input type="hidden" name="_method" value="patch">
is missing from the HTML, so rails doesn't know it is aPATCH
method.Could this be related to https://github.com/DavyJonesLocker/client_side_validations/pull/862 mentioned in the CHANGELOG? Is that something I should adjust on my code?
Expected behavior
Requests coming from JS should use the correct HTTP method.
Actual behavior
Requests coming from JS are using a wrong HTTP method.
System configuration
Rails version: 6.1.4.4
Ruby version: 2.7.4
Client Side Validations version: 20.0.0
Code snippet from your model of the validations
Not relevant; it happens regardless of which validations are being used
The whole form code from your template
The resulting HTML
Regular
form
element, but<input type="hidden" name="_method" value="patch">
is missing.Browser's development console output
Additional JavaScript Libraries
n/a
Repository demostrating the issue
n/a