#---
# Excerpted from "Rails Recipes"
# We make no guarantees that this code is fit for any purpose. 
# Visit http://www.pragmaticprogrammer.com/titles/fr_rr for more book information.
#---
class PostsController < ApplicationController

  def save_draft
    session[:post_draft] = Post.new(params[:post])
    render :text => "<i>Post zapisany o #{Time.now}</i>"
  end


  def new
    if request.get?
      @post = session[:post_draft] || Post.new
    else 
      @post = Post.create(params[:post])
      session[:post_draft] = nil
      redirect_to :action => 'list'
    end
  end

end
