From cbdb0d11742581407108d2300c5caf61787c6fe8 Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 15 Feb 2009 20:58:47 +0100 Subject: more nodes controller functionality --- app/controllers/nodes_controller.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'app/controllers/nodes_controller.rb') diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index cc1ad5c..19fbb57 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -3,13 +3,13 @@ class NodesController < ApplicationController layout 'admin' before_filter :find_node, :only => [:create, :show, :edit, :update, :destroy] - def index @nodes = Node.root.children.all(:include => :head) end def new + end def create @@ -33,11 +33,25 @@ class NodesController < ApplicationController def update draft = @node.find_or_create_draft current_user - draft.update_attributes params[:page] - draft.save + if request.post? && draft.update_attributes( params[:page] ) + redirect_to(@node) + else + render :action => :edit + end end def destroy + @node.destroy + end + + def publish + @node.publish_draft! + end + + def move_to + parent = Node.find params[:parent_id] + @node.move_to_child_of parent + redirect_to(@node) end private -- cgit v1.3