title: what's a RESTful way to save draft posts?
body: <p>I have a posts controller on a small test website I'm making. I want to have a 'save draft'/combo-auto-save function to the site, as the site will have long posts that users may want to leave and come back to finish. However, I've never built an autosave/save function into a Rails app before (or any app). What is a good, RESTful way to do so?</p>
  
  <p>Here is my current controller action:</p>
  
  <p>posts_controller.rb</p>
  
  <pre><code> def create
  
   @post = params[:post]
   if @post.save
       flash.now[:success] = "Post created!"
   else 
       render_errors_now(@post) 
   end
       respond_to do |format|
             format.html {redirect_to Discussion.find(session[:discussion_id])}
             format.js
       end
   end
  </code></pre>
  
  <p>As you can see, users post remotely.</p>
  
  <p>Here is the current post.rb model:</p>
  
  <pre><code> attr_accessible :content, :title
   validates :title, :presence =&gt; true 
   validate :title_character_length
  
   validates :content, :length =&gt; { :maximum =&gt; 10000 }
   validates :user_id, :presence =&gt; true
   validates :discussion_id, :presence =&gt; true
   belongs_to :user
   belongs_to :discussion
   default_scope :order =&gt; 'posts.created_at ASC'
  
   def title_character_length
      #some code that checks length
   end
  </code></pre>
  
  <p>I would need to accomplish the following things from this code..</p>
  
  <ol>
  <li>Auto-save periodically (1 min intervals, perhaps)</li>
  <li>Give option to save draft</li>
  <li>Choose which validations to run: I would want to allow users to, for example, save a draft with a title that exceeds the allowed length, while not allowing them to actually post  a post with that title.</li>
  </ol>
  
  <p>I also am curious what is a good Rails practice for saving drafts: should I add an attribute "draft" to the post model? Or create a draft posts model?</p>
  
  <p>OK please comment if I need to provide more info. I'm interested to hear people's input! Thanks everyone!</p>