TrestleAdmin / trestle

A modern, responsive admin framework for Ruby on Rails
https://trestle.io
GNU Lesser General Public License v3.0
1.97k stars 177 forks source link

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

Open MaximShaikovskiy opened 2 months ago

MaximShaikovskiy commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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.