Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When saving a form, it sends a GET request instead of POST. #489

Open
MaximShaikovskiy opened this issue Sep 12, 2024 · 6 comments
Open

Comments

@MaximShaikovskiy
Copy link

MaximShaikovskiy commented Sep 12, 2024

I'm trying to create an entity. Locally it works as it should, I launched a local production environment and it also works. On
The stage server sends only GET at once. Same thing in 0.10.0pre.
Screenshot from 2024-09-12 13-30-10
Screenshot from 2024-09-12 13-30-03
These are requests from the same form, one locally and the other from the server
Screenshot from 2024-09-12 13-35-56
This is the form itself in the layout on the server, ideally it should send POST

@spohlenz
Copy link
Member

I'm not sure what could be happening, but it looks like your two network request screenshots are showing two different things -- the first on localhost shows the POST request to im_admissions (/admin/im_admissions) which indicates the form submission, and correctly a POST.

The second on new.siil.ch shows the GET request to new (presumably /admin/im_admissions/new) which is the path to the form page itself, which I would expect to see as a GET request.

Is there a POST request showing on staging once you submit the form?

@MaximShaikovskiy
Copy link
Author

MaximShaikovskiy commented Sep 12, 2024

Screencast from 12.09.2024 15:45:48.webm
Yes, this is very strange behavior, I recorded a video to show that I press the update button and a GET request is sent

@spohlenz
Copy link
Member

Pausing the screencast at 0:15 I can see that there was a POST request, before it redirects to the show form action and does a GET request.

Screenshot 2024-09-12 at 10 23 59 PM

Having said that, there does appear to be something odd going on with the double navigation showing in the first few seconds of the video. Is this something you see across all of your admins or just this particular one? Would you be able to share some of your admin's form code?

@MaximShaikovskiy
Copy link
Author

MaximShaikovskiy commented Sep 12, 2024

authorization is done through gem 'trestle-auth', '0.5.0.pre' even if there is a post request on production.log only GET is processed
Screenshot from 2024-09-12 16-05-44

form do |im_admission|
    text_field :title
    text_field :subtitle
    text_field :entry_title
    text_area :entry_text
    text_field :left_tag
    text_field :right_tag
    select :language, [:ru, :en, :fr]

    row do
      col(xs: 6) { image_tag(im_admission.image.url) if im_admission.image.present? }
      col(xs: 6) { file_field :image }
      col(xs: 6) { image_tag(im_admission.image_2x.url) if im_admission.image_2x.present? }
      col(xs: 6) { file_field :image_2x }
    end
  end

I have now created another admin, the same thing happens under him

@MaximShaikovskiy
Copy link
Author

I apologize for thinking about your gem. It turned out that the problem was in nginx - POST /admin/im_admissions/1 HTTP/1.1" 413. I’m not a devops, it’s just a company saving money, so it took me a long time to find out what the reason was. Thank you for telling me to pause the video and see the request.

@spohlenz
Copy link
Member

I'm glad you were able to find the solution, as I was running out of ideas. I am a little surprised that Trestle didn't show an error modal when the 413 status response was received so I will definitely investigate that further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants