Hi, I have a form, When i click submit button twice, My form gets submitted twice, and 2 entries are saved. But I need only 1 entry to be saved. Any idea on how to do it? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Norbert Melzer
2010-Nov-18 08:58 UTC
Re: Double click the submit button, submits form twice
Hidden field wich unique ID. If the ID is submitted twice, omit the new entry Am 18.11.2010 09:56 schrieb "Srikanth Jeeva" <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> Hi, > > I have a form, When i click submit button twice, > My form gets submitted twice, and 2 entries are saved. > > But I need only 1 entry to be saved. > Any idea on how to do it? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups"Ruby on Rails: Talk" group.> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email torubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> .> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.>-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Karuppasamy M.
2010-Nov-18 09:08 UTC
Re: Double click the submit button, submits form twice
Norbert Melzer wrote in post #962309:> Hidden field wich unique ID. If the ID is submitted twice, omit the new > entry > > Am 18.11.2010 09:56 schrieb "Srikanth Jeeva" <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>: >> >> -- >> You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>> . >> For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en.Please try this. When the save functionality completed, you should redirect to the previous action, if you are not using the action both "Page Display" and "Save Process" ex: -- # display the page. localhost/controller/display def display .. .. .. end def save_details .. .. .. [b]redirect_to :action => "display"[/b] end So, when the first click of save button, the action "save_details" will be called and redirected to the first action "display". Now the reloaded page is fresh, i.e the id is unique. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Srikanth Jeeva
2010-Nov-18 10:28 UTC
Re: Double click the submit button, submits form twice
Norbert Melzer wrote in post #962309:> Hidden field wich unique ID. If the ID is submitted twice, omit the new > entry >That did it. Thanks all for reply. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder
2010-Nov-18 14:25 UTC
Re: Double click the submit button, submits form twice
On Thu, Nov 18, 2010 at 12:58 AM, Norbert Melzer <timmelzer-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:>> I have a form, When i click submit button twice, >> My form gets submitted twice, and 2 entries are saved. >> >> But I need only 1 entry to be saved.> Hidden field wich unique ID. If the ID is submitted twice, omit the new > entryBut suppose the user clicks submit, instantly recognizes an error in the information, hits stop, corrects the error, and clicks submit again? If you discard the *second* submission, there is now a discrepancy between what the user intended and what you''ve stored. Uh-oh. Might want to give that a little more thought :-) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2010-Nov-18 14:30 UTC
Re: Double click the submit button, submits form twice
On Nov 18, 2010, at 9:25 AM, Hassan Schroeder wrote:> On Thu, Nov 18, 2010 at 12:58 AM, Norbert Melzer > <timmelzer-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >>> I have a form, When i click submit button twice, >>> My form gets submitted twice, and 2 entries are saved. >>> >>> But I need only 1 entry to be saved. > >> Hidden field wich unique ID. If the ID is submitted twice, omit the >> new >> entry > > But suppose the user clicks submit, instantly recognizes an error in > the information, hits stop, corrects the error, and clicks submit > again? > > If you discard the *second* submission, there is now a discrepancy > between what the user intended and what you''ve stored. Uh-oh. > > Might want to give that a little more thought :-)Are you trying to trap a "bounce" here -- a double-click because of machine or user error that is being interpreted as two separate submit events? You can easily trap those by adding :disable_with => ''Saving...'' to your button tag. Only the first click will be accepted, and the button will gray out and stop accepting input after that. Happens at the JavaScript level, so the response will be very nearly immediate. Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker
2010-Nov-18 15:41 UTC
Re: Double click the submit button, submits form twice
Hassan Schroeder wrote in post #962339:> On Thu, Nov 18, 2010 at 12:58 AM, Norbert Melzer > But suppose the user clicks submit, instantly recognizes an error in > the information, hits stop, corrects the error, and clicks submit again? > > If you discard the *second* submission, there is now a discrepancy > between what the user intended and what you''ve stored. Uh-oh.Besides fixing the double-submission problem in the view layer you might also want to add appropriate unique indexes to prevent the possibility of duplicates at the database level. Doing so will at lease ensure data integrity and prevent insert race conditions. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.