Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well first off this is typical behavior in a rails application out of the box. </p> <p>If someone submits an invalid form, then refreshes the page, what is supposed to happen? In the case you have seen and in typical rails apps, we just refresh and (in the case of updating a record) possibly pop them out of the user experience. IMO, that's OK. Refreshing sometimes breaks the web :)</p> <p>This is commonly seen when a designer wants to change the styling of the "invalid" page or a developer is looking at a rendering bug on the error page, they fix the code or css then refresh the page possibly expecting to see the page fixed but instead they might get and error related to /plumbers not accepting get requests or they get put back on the plumbers#index page.</p> <p>Short answer is usually this isn't a big deal on most rails apps and it is done this way so that we don't have to rely on storing their answers and errors in session temporarily just to redirect back to the edit page, it all gets done in one request and response cycle.</p> <p>If you want to change the behavior you can do something like</p> <pre><code> class PlumbersController def update plumber = Plumber.find(params[:id]) if plumber.update(params[:plumber]) redirect_to(plumbers_path, :message =&gt; "successfully updated!") else flash[:plumber_attributes] = params[:plumber] redirect_to plumber_edit end end def edit @plumber = Plumber.find(params[:id]) @plumber.assign_attributes(flash[:plumber]) if flash[:plumber.present?] end end </code></pre> <p>NOTE: this code hasn't been tested. The general idea is to pop plumber attributes into flash and redirect to the plumbers edit URL.</p> <p>That said, the behavior your are describing is typical and the only way for rails to get around it is to rely on session (flash) for application logic, which it chooses not to do out of the box.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload