Sha256: 48365e093341c5b4959b922247df362bbd643a5aad701638d1ebaadd0cf686b2
Contents?: true
Size: 1.3 KB
Versions: 5
Compression:
Stored size: 1.3 KB
Contents
require_dependency 'trackback' class DraftController < ApplicationController before_filter :auth_required def index list render_action 'list' end def list @drafts = current_user.drafts.find_all(nil, 'created_at ASC') end def new @draft = Draft.new if @request.post? @draft.attributes = @params['draft'] @draft.user = current_user if @draft.save flash['notice'] = "Draft was successfully saved." return end end end def edit begin @draft = Draft.find(@params['id']) rescue ActiveRecord::RecordNotFound redirect_to_draft return end if @request.post? @draft.attributes = @params['draft'] if @draft.save flash['notice'] = "Draft was successfully saved." redirect_to_draft end end end def post begin draft = Draft.find(@params['id']) post = current_user.posts.build post.subject = draft.subject post.body = draft.body post.save send_trackback(post, draft.tb_url, @app_config) unless draft.tb_url.empty? draft.destroy rescue ActiveRecord::RecordNotFound end redirect_to_draft end def destroy Draft.find(@params['id']).destroy rescue nil redirect_to_draft end end
Version data entries
5 entries across 5 versions & 1 rubygems