自动保存表单草稿

How does Stack Overflow auto save drafts of this form? I presume AJAX. Is there a rails way or gem to use this functionality?

Also, is it actually a separate drafts model or is the form auto created and then from there on out the edit action is being used?

I know I'm asking specifically about Stack Overflow's usage, but, generally speaking.

First you should get the text that you want to save in database using jquery like this:

var text=$("#textToBeSaved").val();

then you should make your code to call the server page that would save the text in the database like this:

$(".sumButton").click(function()
{
    var text=$("#textToBeSaved").val();
    $.post("pageThatWillSaveToDB.php",{textToBeSaved:text},function(result)
    {
        alert("The Data is Saved");
    }
});

and in the page that named pageThatWillSaveToDB.php you should do this code:

$text=$_POST['textToBeSaved'];
// connectToDatabase();
mysql_query("insert into SomeTable values(null,'{$text}')");

You can use Sisyphus.js or Garlic.js. While StackOverflow uses AJAX, they use HTML5 localStorage to save form data locally.

Rails gems: garlicjs-rails, sisyphus-rails.