Duplicate comments using remote_form_for

Is there a best practice way to prevent duplicate comments (or whatever
the model may be) submissions from a remote_form_for? Maybe a time-based
validation, like the way WordPress seems to prevent comments being
posted less than 60 seconds apart(?). At the moment, my app allows users
to double click (or more) on the 'Submit' button and, therefore,
duplicate their comment very easily.

I don't have a validates uniqueness of on the comment.user_id and
comment.body because it wouldn't be appropriate in this app - we want
people to be able to post the same comment more than once, at least to a
certain extent. Is there another way to validate this? Or do I need to
resort to deactivating/hiding the submit button after a requested is
made and only showing it again once the comment has been posted?

You can always make submit button inactive using javascript in :before
=> "" block, and then activate it agan (possibly also clearing body of
comment) in :after => '" javascript block.

Also, you can place some indicator, like spinning box to notify user
that his/her post is being sent.

Hubert Łępicki wrote:

You can always make submit button inactive using javascript in :before
=> "" block, and then activate it agan (possibly also clearing body of
comment) in :after => '" javascript block.

Also, you can place some indicator, like spinning box to notify user
that his/her post is being sent.

On Aug 7, 9:06�am, Neil Cauldwell <rails-mailing-l...@andreas-s.net>

Yes, I have a 'spinner' element in the layout. I was considering
replacing the button with one, but seeing as I prefer to have just one
place for the spinner (could make for a cleaner user experience and
development experience!) I do like the sound of the javascript in
:before => "" block. I'll admit, I'm a little confused by what you mean
as I haven't come across the :before, :after (except for before_create
filters - presumably not the same thing). Do they go in the comment
create.js.rjs template or, are they options for the remote_form_for
helper, like the way that :loading and :complete work for indicators?

Finally (sorry for 101 questions) is there any easy way to deactivate a
submit button, maybe removing the 'submit' value?

Thanks.

Neil Cauldwell wrote:

Hubert Łępicki wrote:

You can always make submit button inactive using javascript in :before
=> "" block, and then activate it agan (possibly also clearing body of
comment) in :after => '" javascript block.

Also, you can place some indicator, like spinning box to notify user
that his/her post is being sent.

On Aug 7, 9:06�am, Neil Cauldwell <rails-mailing-l...@andreas-s.net>

Yes, I have a 'spinner' element in the layout. I was considering
replacing the button with one, but seeing as I prefer to have just one
place for the spinner (could make for a cleaner user experience and
development experience!) I do like the sound of the javascript in
:before => "" block. I'll admit, I'm a little confused by what you mean
as I haven't come across the :before, :after (except for before_create
filters - presumably not the same thing). Do they go in the comment
create.js.rjs template or, are they options for the remote_form_for
helper, like the way that :loading and :complete work for indicators?

Finally (sorry for 101 questions) is there any easy way to deactivate a
submit button, maybe removing the 'submit' value?

Thanks.

And after a little bit of searching, I came across a very, very easy
solution to go in the form_remote_for options;

:loading => "Element.show('spinner');
$('comment_submit').disabled='disabled';",
:complete => "Element.hide('spinner'); $('comment_submit').disabled='';"

I hope that helps someone.