Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6688169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:22:25+00:00 2026-05-26T05:22:25+00:00

A follow up to this question: what's a RESTful way to save draft posts?

  • 0

A follow up to this question: what's a RESTful way to save draft posts?

I’m wondering, the submissions that are created always submit to the “create” action in rails. How can I make:

  1. The first autosave create an entry
  2. All subsequent autosaves update the saved entry
  3. The final submission update the same entry

For information, see the related question first. Also, I’m doing this on the Post model, where I added a field “draft” that can be true or false. My jQuery submission is:

 $(document).ready(function() {
    $('#new_post').append('<div class="temp"> </div>');
    setInterval(function() {

      { $('#new_post .temp').html('<input type="hidden" name="post[draft]" id="post_draft" value="true" />');
  draft = $('#draft');
}

      $('#post_form form[data-remote]').submit();

     $('#new_post .temp').html('');
      }, 1000*30); // 1000ms * 60s = 1m

 });

This file creates a hidden field “draft”, submits the form, and then deletes the field.

Also, another file that may be of use is create.js.erb. Once the form is submitted to the controller, this embedded ruby javascript file is called and run. Currently, I make a variable “draft” available to the file such that:

 <% if draft %>
      #maybe putting code here can change the form to submit to "update" action next time?
 <% else %>
      # code that executes if it's a final submission, updating tables etc..
 <% end %>

Maybe this file is a place to accomplish my task?

If there is more information required, let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:22:25+00:00Added an answer on May 26, 2026 at 5:22 am

    Maybe you can try this: After you get back the post id from the first ajax form submit, you can modify subsequent form submit to supply the post id and change the form method from POST to UPDATE. That should be a restful way of triggering record updates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In follow up to this question , it appears that some numbers cannot be
This is basically a follow-up to this question: Can I create a placeholder iPhone
This question is a follow up of this question. How can I achieve that
As a follow-up to this question Here is some code that compiles and runs
Follow-to this question: The Dual Nature of svn:ignore Is there any way to accomplish
Follow up to this question . I have the following code: string[] names =
Follow up to this question about GNU make : I've got a directory, flac
This question is a follow on from this one ... I am binding to
[a follow up to this question ] class A { public: A() {cout<<A Construction
As a follow up to this question: Developing a online exam application, how do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.