In rails controllers, how to prevent double submit (when user double-clic submit button or hit enter twice)?

后端 未结 8 2303
天命终不由人
天命终不由人 2021-02-19 09:50

Well, everything\'s in the title but I\'ll explain a little more :-)

My rails app contain many forms (Ajaxified or not).

To prevent users to submit twice or more

8条回答
  •  遥遥无期
    2021-02-19 10:13

    Not sure if this is helpful:

    ON SERVERSIDE:

    1. On fresh load of the form, set a session['variable']=false //meaning the form isn't submitted yet.

    2. On form submit, check:

      if session['variable'] == true
      {
         do nothing...
      }
      else
      {
         set session['variable'] = true;
        //do submit logic here
      }
      

提交回复
热议问题