Hi, We occasionally have a user pressing "submit" button more than once. I know I can disable submit button using "onclick". But I sometimes need a more solid solution especially for a form that could change a record inside the database. What could be the best way to solve the problem? I need to access to the existing database record first and compare the record with a new coming record. I am now thinking about checking almost all attributes. Assuming this is a simple blog, I would check the title and post for exact match. I was trying to find an open source Rails app to have a solution, do you know any? Any help would be appreciated. Jon
If I''m following you correctly, check out the RailsSpace book site. You can download the final application. In the application, look at the comments conroller in the create action. He''s checking for duplicates and throwing them out if so. http://www.railsspace.com/ I hope that''s what you meant...
On Sep 5, 12:30 pm, Hunt Jon <jona.hunt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > We occasionally have a user pressing "submit" button more than once. > I know I can disable submit button using "onclick". > > But I sometimes need a more solid solution especially > for a form that could change a record inside the database. >Optimistic locking etc ? Fred> What could be the best way to solve the problem? > I need to access to the existing database record first and > compare the record with a new coming record. > > I am now thinking about checking almost all attributes. > Assuming this is a simple blog, I would check the title > and post for exact match. > > I was trying to find an open source Rails app to have > a solution, do you know any? > > Any help would be appreciated. > > Jon
Shoot users that do this - it''s the only way to be sure. :) --Matt Jones On Sep 5, 12:50 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sep 5, 12:30 pm, Hunt Jon <jona.hunt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > We occasionally have a user pressing "submit" button more than once. > > I know I can disable submit button using "onclick". > > > But I sometimes need a more solid solution especially > > for a form that could change a record inside the database. > > Optimistic locking etc ? > > Fred > > > > > What could be the best way to solve the problem? > > I need to access to the existing database record first and > > compare the record with a new coming record. > > > I am now thinking about checking almost all attributes. > > Assuming this is a simple blog, I would check the title > > and post for exact match. > > > I was trying to find an open source Rails app to have > > a solution, do you know any? > > > Any help would be appreciated. > > > Jon
If you are updating any state or flag on first submit; you can possibly generate an exception if that flag is already set and second submit tries to set it again. Then you can catch it (rescue) and ignore or display the error/message accordingly. Hope it helps. Thanks, Abhinav -- अभिनव http://twitter.com/abhinav On Sat, Sep 5, 2009 at 5:00 PM, Hunt Jon <jona.hunt777-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > We occasionally have a user pressing "submit" button more than once. > I know I can disable submit button using "onclick". > > But I sometimes need a more solid solution especially > for a form that could change a record inside the database. > > What could be the best way to solve the problem? > I need to access to the existing database record first and > compare the record with a new coming record. > > I am now thinking about checking almost all attributes. > Assuming this is a simple blog, I would check the title > and post for exact match. > > I was trying to find an open source Rails app to have > a solution, do you know any? > > Any help would be appreciated. > > Jon > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---