# Periodically autosave form

**URL:** <https://www.ruby-forum.com/t/periodically-autosave-form/167542>\
**Category:** Rails\
**Created:** [May 9, 2009, 4:39am UTC](https://www.ruby-forum.com/t/periodically-autosave-form/167542 "2009-05-09T04:39:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 9, 2009, 4:39am UTC](https://www.ruby-forum.com/t/periodically-autosave-form/167542/1 "2009-05-09T04:39:35Z")

</div>

Would someone show how to implement a periodical save of a form in the  
background? Same kinda thing that gmail does. I would like to  
autosave a form ajax wise so a technician in the field would have it  
saved off in case of a wireless disconnect while filling out a form.  
thanks.

I would guess on doing the periodically call remote but how do you  
submit the form?

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 9, 2009, 4:51am UTC](https://www.ruby-forum.com/t/periodically-autosave-form/167542/2 "2009-05-09T04:51:16Z")

</div>

A caveat, It has to be done with the form already having been  
created. So doing an observe form with a form id will not work as the  
form id id being generated by rails as it is in edit mode.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 9, 2009, 5:26am UTC](https://www.ruby-forum.com/t/periodically-autosave-form/167542/3 "2009-05-09T05:26:55Z")

</div>

I am not sure about your situation, but I would use observe\_form set  
and :frequency to seconds at which changes to this field will be  
detected. This should work with the existing form.

See the documentation.  
[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html)

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 11, 2009, 11:54am UTC](https://www.ruby-forum.com/t/periodically-autosave-form/167542/4 "2009-05-11T11:54:06Z")

</div>

In this case, he does not even have to observe the form.

He can just call a script on page load which shoots off an Ajax submit  
and update on the form every minute or so.
