# How to stop invoke a method more than one times

**URL:** <https://www.ruby-forum.com/t/how-to-stop-invoke-a-method-more-than-one-times/128599>\
**Category:** Rails\
**Created:** [February 9, 2008, 5:44am UTC](https://www.ruby-forum.com/t/how-to-stop-invoke-a-method-more-than-one-times/128599 "2008-02-09T05:44:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [February 9, 2008, 5:44am UTC](https://www.ruby-forum.com/t/how-to-stop-invoke-a-method-more-than-one-times/128599/1 "2008-02-09T05:44:16Z")

</div>

How to stop invoking a method more than one times when this method has  
submitted to server.My shopping system have methods to manage  
bill,ship,pay…  
But i found when i was submitting a method such as bill,i can still  
flush or use keyboard in the browser to invoke this method many  
times.This will make one cart corresponding many  
bill,ship,pay…parts.But i wish that one cart can only correspond one  
bill,ship,pay…part.How do i make this reality?  
Thank you

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [February 9, 2008, 9:35am UTC](https://www.ruby-forum.com/t/how-to-stop-invoke-a-method-more-than-one-times/128599/2 "2008-02-09T09:35:27Z")

</div>

You could use JavaScript to disable the submit after the first time.

On Feb 9, 5:44 am, Guo Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [February 9, 2008, 10:29am UTC](https://www.ruby-forum.com/t/how-to-stop-invoke-a-method-more-than-one-times/128599/3 "2008-02-09T10:29:25Z")

</div>

Use the :disable\_with parameter in your form submit tag

On Feb 9, 9:44 am, Guo Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [February 10, 2008, 9:44am UTC](https://www.ruby-forum.com/t/how-to-stop-invoke-a-method-more-than-one-times/128599/4 "2008-02-10T09:44:35Z")

</div>

Thank you!I will try it.It should be like that.

Mukund wrote:

> Use the :disable\_with parameter in your form submit tag
> 
> On Feb 9, 9:44 am, Guo Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
