[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Mukund
enter just processes the submit button. if you disable the submit button, then enter key press will be disabled as well. personally, i would get rid of the submit tag and use a image_submit_tag to get rid of stupid keyboard annoyances. This will force the user to click on the link to submit

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Jim Burgess
Thanks for all of the answers. I solved it a little differently and will explain how in case a) it helps anybody else b) there is a flaw in my method which I have overlooked What I did was in the controller: Create a model object: @applicant = Applicant.new(params[:applicant]) Wait for a post

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Aldric Giacomoni
Good to hear that you've solved the problem yourself. Is now too late to point out that you could probably use validates_uniqueness_of in your model? http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M002167 -- Posted via http://www.ruby-forum.com/.

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Matt W.
I have a similar problem that I'm working on, but I was going to take a slightly different approach. My problem is that I'm collecting completely anonymous data at first, but then I want people to be able to come in later and create an account, then hopefully be able to find their records. I'm

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Kyle F
If you dont want duplicate data then just add the following to the model. Thats where validation should be. validates_uniqueness_of :email_address On Aug 27, 8:43 am, Matt W. m...@squid37.com wrote: I have a similar problem that I'm working on, but I was going to take a slightly different

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Jim Burgess
Thanks for the replies. I'm also not sure if doing the validation in the model would work. Assuming that the user has a slow connection and hits submit on the form twice, then the first time the email would be unique, so everything would be good. However, would it not be the case that the

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Aldric Giacomoni
And maybe one more.. Again, I know you dislike javascript, but.. :) This isn't exactly generic - I'm pulling it straight out of something I'm doing right now. Why not show a spinner (and disable the submit button?) when they press submit and hide the spinner when that's done ? It's all about

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Matt W.
After talking to some friends of mine, the IP address is NOT a good idea...looks like I'll be looking at a cookie solution instead. On Aug 27, 7:43 am, Matt W. m...@squid37.com wrote: I have a similar problem that I'm working on, but I was going to take a slightly different approach. My

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Jim Burgess
That's a cool idea. I will also have a play around with that this evening. Thank you very much. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group.

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-27 Thread Matt Jones
The problem is that your users, like most users, are not very bright. They double-click (or in this case, triple-click) submit buttons. :disable_with will pretty much solve the issue; anybody with enough savvy to have JS disabled likely knows that you don't double- click submit buttons. --Matt

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Jim Burgess
Aldric Giacomoni wrote: Quick hit from google after using disable form rails after click: http://railsforum.com/viewtopic.php?id=9585 Hope this helps. Cheers for the reply, but this is quick and dirty and doesn't solve the problem if the user has javascript disabled. I would rather

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Aldric Giacomoni
Quick hit from google after using disable form rails after click: http://railsforum.com/viewtopic.php?id=9585 Hope this helps. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Aldric Giacomoni
Jim Burgess wrote: Thanks for the reply. I am still confused though, as to why I cannot reproduce the error. When I press submit ten times in quick succession then only one data set is submitted. Are you trying from the server? A computer on the same switch? On the same subnet? Remember,

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Aldric Giacomoni
Jim Burgess wrote: I would rather understand what is happening when submit is pressed and work things out from there. In my very limited understanding of the web, this is what happens: 1) data is entered 2) 'submit' is pressed 3) Asynchronous request is sent. If there is a way to make a form

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Jim Burgess
Thanks for the reply. I am still confused though, as to why I cannot reproduce the error. When I press submit ten times in quick succession then only one data set is submitted. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Aldric Giacomoni
Jim Burgess wrote: No. I'm at home on my computer, the application is on a web server somewhere in Germany (as far as I know). I will however try to create the error from a different computer, see if that works. Can you reproduce the same kind of traffic surrounding the times when the

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Jim Burgess
No. I'm at home on my computer, the application is on a web server somewhere in Germany (as far as I know). I will however try to create the error from a different computer, see if that works. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Jim Burgess
It's the blind leading the blind here, :-) It was last night and there was relatively little going on. I don't think traffic is the problem. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Frederick Cheung
On 26 Aug 2009, at 16:02, Jim Burgess wrote: I have a standard form built with rails, which a user to my site can use to submit data. Unfortunately one user just managed to submit exactly the the same data three times in a row. From the server logs it seems as though he didn't use his

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Patrick Doyle
Is the user who caused the problem friendly or malicious? If (s)he is (or could be) malicious, then perhaps (s)he didn't use a browser to create three records in your database, but instead wrote some code to post three times in quick succession. I just added a sleep 5 to my #create method and

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread JL Smith
They could have also hit the 'enter' key multiple times too, not clicking anything. But in either case, a small amount of javascript will prevent this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails:

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Aldric Giacomoni
Jim Burgess wrote: It's the blind leading the blind here, :-) It was last night and there was relatively little going on. I don't think traffic is the problem. Well, then it's time to sacrifice a goat. How long does it take once the button is pressed? Try pressing it once, then again

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Frederick Cheung
On Aug 26, 7:27 pm, Jim Burgess rails-mailing-l...@andreas-s.net wrote: I have just finished entering the same data into IE and was rather surprised to see that I could submit it many times. So, it seems to be the case that Firefox 3.5 surpresses this behaviour, whilst IE lets you submit

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Greg Donald
On Wed, Aug 26, 2009 at 10:09 AM, Jim Burgessrails-mailing-l...@andreas-s.net wrote: I would rather understand what is happening when submit is pressed and work things out from there. You can put a hidden field in your form, detect it and then set a session variable. Then don't process any

[Rails] Re: How to stop a user submitting the same data more than once.

2009-08-26 Thread Jim Burgess
Lee Smith wrote: They could have also hit the 'enter' key multiple times too, not clicking anything. But in either case, a small amount of javascript will prevent this. To prevent the submit button being pressed many times I am using %= submit_tag Submit, :onclick = this.disabled = true %